小编Ale*_*kov的帖子

Hibernate + MySQL:如何为数据库和表设置编码utf-8

我的系统运行在Linux Mandriva,RDBMS - MySQL 5上.我需要使用UTF-8创建数据库和表.

这是hibernate.cfg.xml的一个片段-

... 
 <property name="hibernate.hbm2ddl.auto">create-drop</property>   
 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
 <property name="hibernate.connection.characterEncoding">utf8</property> 
...
Run Code Online (Sandbox Code Playgroud)

my.cnf -

# The MySQL server
[mysqld]
...
default-character-set=cp1251
character-set-server=cp1251
collation-server=cp1251_general_ci
init-connect="SET NAMES cp1251"
skip-character-set-client-handshake
...
[mysqldump]
...    
default-character-set=cp1251
...
Run Code Online (Sandbox Code Playgroud)

有些课,例如 -

@Entity
@Table(name = "USER")
public class User {
    @Id 
    @Column(name = "USERID")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    @Column(name = "USERNAME")
    private String name;

    @Column(name = "USERPASSWORD")
    private String password;

    @Column(name = "USERIP")
    private String ip;
        // …
Run Code Online (Sandbox Code Playgroud)

mysql linux hibernate jpa character-encoding

25
推荐指数
5
解决办法
7万
查看次数

SP元数据:用于签名和加密的证书

规范说:

OASIS安全断言标记语言(SAML)V2.0的元数据

2.4.1.1元素 <KeyDescriptor>

<KeyDescriptor>元素提供有关实体用于签名数据或接收加密密钥的加密密钥的信息,以及其他加密详细信息.其 KeyDescriptorType复杂类型包含以下元素和属性:

use[可选的]

可选属性,指定所描述的密钥的用途.值是从KeyTypes枚举中提取的,由值encryption和值组成signing.

<ds:KeyInfo>[需要]

直接或间接标识密钥的可选元素.

据我所知,为了向两个方向发送安全数据,我应该:

  1. 我自己的私钥
  2. 我自己的公钥
  3. 收件人的公钥

我应该在SP元数据中指定什么密钥的证书,并且我可以使用相同的证书进行签名和加密?

IdP的供应商提供了所谓的"元数据模板",其中指出了应该拼写的内容和位置.

这是相关部分(逐字):

...
<md:KeyDescriptor use="signing"> 
   <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> 
      <ds:X509Data> 
         <ds:X509Certificate> 
            <!--
             TODO It is necessary to insert here the certificate of the signature 
             key of the service provider in X509 DER format and Base64 encoded
             --> 
          </ds:X509Certificate> 
      </ds:X509Data> 
   </ds:KeyInfo> 
</md:KeyDescriptor> 

<md:KeyDescriptor use="encryption"> 
   <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> 
      <ds:X509Data> 
         <ds:X509Certificate> 
            <!--
             TODO It is necessary to insert here the certificate of …
Run Code Online (Sandbox Code Playgroud)

cryptography shibboleth service-provider saml-2.0

6
推荐指数
1
解决办法
5398
查看次数

Spring MVC + Zepto POST中出现"Access-Control-Allow-Origin"错误

我正在尝试将JSON对象发布到我的Spring MVC控制器,但我只收到Access-Control-Allow-Origin错误.

我的控制器:

@RequestMapping(value= "/add", method = RequestMethod.POST, headers = {"content-type=application/json"})
public @ResponseBody Reponse addUser(Model model, @RequestBody @Valid @ModelAttribute("user") User user, BindingResult result) {
    if (result.hasErrors()) {
        Reponse error = new Reponse();
        // etc......
        return error;
    } else {
        return service.addUser(user);
    }
}
Run Code Online (Sandbox Code Playgroud)

我的Zepto POST:

this.addUser = function (valeur, callback) {
    $.ajax({
        type: 'POST',
        url: 'http://127.0.0.1:8080/AgenceVoyage/user/add',
        data: JSON.stringify({"mail" : "toto@toto.fr" , "password" : "titi"}),
        dataType: "json",
        contentType: "application/json",

        success: function(data) {
            if(data.reponse == "OK") {
                window.location = "main.html"; …
Run Code Online (Sandbox Code Playgroud)

ajax post spring spring-mvc zepto

5
推荐指数
1
解决办法
9622
查看次数

对Spring MVC Controller的AJAX POST请求无法正常工作

我面临错误:

无法加载资源:服务器响应状态为415(不支持的媒体类型)

我的代码的AJAX部分如下:

$.ajax({ 
    url: '/authentication/editUser',    
    type: "POST", 
    contentType: "application/json",
    data: JSON.stringify(requestObj), //Stringified JSON Object

    success: function(resposeJsonObject) {
       //
    }   
});
Run Code Online (Sandbox Code Playgroud)

和控制器的处理程序方法:

@RequestMapping(value = "/editUser", method = RequestMethod.POST, 
    headers = {"Content-type=application/json"})
@ResponseBody
public  EditUserResponse editUserpost(@RequestBody EditUserRequest editUserRequest) {
    System.out.println(editUserRequest);
    return new EditUserResponse();
}
Run Code Online (Sandbox Code Playgroud)

如何解决错误?

ajax jquery spring json spring-mvc

5
推荐指数
0
解决办法
2万
查看次数

JavaScript - 按部分ID删除元素

我需要删除它上面的 <div>元素id.我知道我可以使用如下的功能 -

function removeElement(div_id) {
   var div = document.getElementById(div_id);
   element.parentNode.removeChild(div);
}
Run Code Online (Sandbox Code Playgroud)

但事实是id- 复合材料.它由一个恒定的部分和每个请求中发生变化的部分组成.这部分是一组随机数.

我知道,在这种情况下我需要使用正则表达式.我会非常感谢一个例子.

html javascript

3
推荐指数
1
解决办法
2235
查看次数

如何在模板Slim中添加带有JavaScript代码的html文件?

有包含JavaScript代码的HTML文件.此JavaScript代码加载图像并将其放置在某个位置.如果失败,则会显示一条消息.

我需要在模板Slim中包含此文件.

我可以通过以下方式将一个Slim模板包含在另一个模板中:

=render 'some/path/some_pattern'
Run Code Online (Sandbox Code Playgroud)

如何将HTML文件包含在我的模板Slim中

谢谢大家.

ruby haml ruby-on-rails slim-lang

3
推荐指数
1
解决办法
6812
查看次数

AJAX在Spring MVC中返回404

ViewResolver(我的jsp位于前缀值指定的右侧文件夹中):

<!-- Resolves views selected for rendering by @Controllers --> 
<!-- to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>
Run Code Online (Sandbox Code Playgroud)

Servlet映射:

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>*.fst</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

控制器:

@Controller
public class HomeController {   
    private static final Logger logger = 
        LoggerFactory.getLogger(HomeController.class);

    @RequestMapping("/home")
    public ModelAndView home(String user, HttpServletRequest request) {
        logger.info("Home controller has been executed");
        ModelAndView mv = new ModelAndView();

        mv.addObject("userName", user);
        mv.addObject("controllerName", request.getRequestURI());
        mv.setViewName("home");

        return mv;
    }

    @RequestMapping(value = "/testAjax", method = RequestMethod.POST) …
Run Code Online (Sandbox Code Playgroud)

ajax spring spring-mvc

3
推荐指数
1
解决办法
6140
查看次数

从Linux内核驱动程序写入文件失败

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>

static int __init hello_start(void)
{
    struct file* my_fd;

    my_fd = filp_open ("/tmp/foobar", O_WRONLY | O_APPEND, 0);
    if (IS_ERR (my_fd))
    {
    printk (KERN_ERR "Failed to open file. err: %d.\n", my_fd);
    }
    else
    {
    my_fd->f_op->write (my_fd, "some data", 10, &my_fd->f_pos);
    }

printk(KERN_INFO "Loading hello module...\n");
return 0;
}

static void __exit hello_end(void)
{
printk(KERN_INFO "hello_end.\n");
}

module_init(hello_start);
module_exit(hello_end);
Run Code Online (Sandbox Code Playgroud)

上面的代码在文件中写入时给出错误-14.我在这做错了什么?

这是dmesg输出:

[19551.674999] Write returned: -14.
[19551.675004] Loading hello module...
Run Code Online (Sandbox Code Playgroud)

c linux-kernel

2
推荐指数
1
解决办法
2606
查看次数

如何使用java程序在浏览器中运行html文件?

这是我的代码.我可以打开浏览器,但不会加载html源代码.

class Browser {
    public static void main(String[]args) {
        try {
            Runtime rtime = Runtime.getRuntime();

            String url = "?C:/Program Files (x86)/Internet Explorer/DD.html";
            String brow = "C:/Program Files (x86)/Internet   Explorer/iexplore.exe";

            Process pc = rtime.exec(brow + url);    
            pc.waitFor();       
         } catch (Exception e) {
              System.out.println("\n\n" + e.getMessage());
         }
    }
}
Run Code Online (Sandbox Code Playgroud)

java

2
推荐指数
1
解决办法
5568
查看次数

外部请求的身份验证-如何在SOAP标头中传递用户凭据?

有一个简单的WCF Web服务。对Web服务的所有外部请求都必须经过身份验证。

Web服务的合同:

namespace SimpleCustomService
{
    [ServiceContract]
    public interface UsrIService
    {
        [OperationContract]
        string SayHello();
    }
}
Run Code Online (Sandbox Code Playgroud)

Web服务的实现:

namespace SimpleCustomService
{
    public class UsrService : UsrIService
    {
        public string SayHello()
        {
            return "Hello";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

通过使用该wsdl.exe实用程序,我生成了代理类来调用Web服务的方法。

生成的代码如下:

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;

// 
// This source code was auto-generated by wsdl, Version=4.6.1055.0.
// 


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="BasicHttpBinding_UsrIService", Namespace="http://tempuri.org/")]
public partial class UsrService : System.Web.Services.Protocols.SoapHttpClientProtocol {

    private System.Threading.SendOrPostCallback SayHelloOperationCompleted; …
Run Code Online (Sandbox Code Playgroud)

c# wcf soap wsdl web-services

2
推荐指数
1
解决办法
4150
查看次数

为什么MultipartEntityBuilder抛出org.apache.http.ContentTooLongException?

我有一个简单的Apache Camel路由,该路由从队列中获取序列化文件并将其发送到一些外部资源:

public class MyRouteBuilder extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("activemq:alfresco-queue")
        .process(new Processor() {
            public void process(Exchange exchange) throws Exception {
                MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
                multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
                multipartEntityBuilder.addPart("file", new ByteArrayBody(exchange.getIn().getBody(byte[].class), 
                        exchange.getIn().getHeader("fileName", String.class)));
                exchange.getIn().setBody(multipartEntityBuilder.build().getContent());              
            }
        })

        .setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.POST))
        .to("http4://vm-alfce5-31.....com:8080/alfresco/s/someco/queuefileuploader?guest=true")

        .process(new Processor() {
            public void process(Exchange exchange) throws Exception {
                System.out.println("The response code is: " + 
                        exchange.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE));
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

蓝图配置文件:

<?xml version="1.0"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

    <bean id="myRouteBuilder" class="org.fusesource.example.MyRouteBuilder"/>

    <camelContext id="blueprintContext" trace="false" …
Run Code Online (Sandbox Code Playgroud)

activemq-classic jms apache-camel apache-httpcomponents jbossfuse

2
推荐指数
1
解决办法
989
查看次数

调度传入的RPC调用时发生异常:encodedRequest不能为空

此处描述了类似的问题:GWT IllegalArgumentException:encodedRequest不能为空

我的GWT应用程序部署在Tomcat6中,它通过使用Coyote/JK2连接器与Apache链接.对于SSO,我使用mod_auth_sspi/1.0.4.

当我使用IE8时,页面不显示,但对于Firefox一切正常.在Tomcat日志中,我看到以下内容:

SEVERE: Exception while dispatching incoming RPC call
java.lang.IllegalArgumentException: encodedRequest cannot be empty
    at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:232)
    at org.spring4gwt.server.SpringGwtRemoteServiceServlet.processCall(SpringGwtRemoteServiceServlet.java:32)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at gov.department.it.server.RequestInterceptorFilter.doFilter(RequestInterceptorFilter.java:90)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:311)
    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
    at java.lang.Thread.run(Thread.java:619)
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试了什么:

1)找不到注册表项DisableNTLMPreAuth(恕我直言,这不是解决方案,因为在我的情况下IE 8是主动使用的).

2)我已经安装并配置了本机Windows身份验证框架WAFFLE

web.xml中:

...
<filter>
    <filter-name>NegotiateSecurityFilter</filter-name>
    <filter-class>waffle.servlet.NegotiateSecurityFilter</filter-class>
    <init-param>
        <param-name>waffle.servlet.spi.NegotiateSecurityFilterProvider/protocols</param-name>
        <param-value>NTLM</param-value> …
Run Code Online (Sandbox Code Playgroud)

apache internet-explorer tomcat ntlm single-sign-on

1
推荐指数
1
解决办法
7548
查看次数

Edgewall Trac:回顾通知

你好,

是否有可能不仅包括在创建故障单和更改故障单时发送的消息中的状态和最新评论?我希望看到更多,比如所有可用的回顾性信息,即整个变更历史记录.

也许有人已经这样配置了Trac.如果是这样,我将非常感谢有关该配置的信息,包括与该应用程序一起使用的Trac版本.

干杯,Thx

trac

0
推荐指数
1
解决办法
215
查看次数