小编Mih*_*ban的帖子

Hibernate 5.1与Postgis 2.2几何列映射

hibernate 5.1 spatial的文档尚未发布(AFAIK),我试图将具有JST几何字段的实体持久化到PostgreSQL 9.5 + Postgis 2.2,没有任何运气.

我还注意到hibernate-core-5.1.0中没有org.hibernate.spatial包.我尝试过以下注释的变体:

@javax.persistence.Column(name = "the_geom", columnDefinition = "Geometry")
public com.vividsolutions.jts.geom.Geometry geom;
Run Code Online (Sandbox Code Playgroud)

当columnDefinition设置为"Point"时,我得到"column",the_geom"的类型为point,但表达式的类型为bytea".在hibernate spatial 4文档中,据说版本5+不需要@Type注释,但应该使用什么呢?如何将geom存储为有效的Postgis几何?

postgresql hibernate postgis

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

使用javascript参数对ajax回调进行Primeface

我正在努力将Primefaces bean属性直接发送到javascript,以便打开一个新页面并将bean属性的内容写入新页面.

我正在使用Primefaces 4.0.

我有一个这样的命令按钮:

 <p:commandButton id="buttonId" update="buttonId, otherComponentId"
    value="press me" process="@this" actionListener="#{homeController.myMethod}"
    oncomplete="handleComplete(xhr, status, args)">
 </p:commandButton>
Run Code Online (Sandbox Code Playgroud)

在handleComplete中,javascript函数args未定义,但不是xhr和status.javascript函数定义:

function handleComplete(xhr, status, args){
    var w = window.open();
    w.document.open();
    alert(xhr.responseText.substring(100));
    alert(status);
    alert(args);
    var d = '<head></head><body>'+ args.firstParam +'<body>';
    w.document.write(d);
    w.document.close();
}
Run Code Online (Sandbox Code Playgroud)

首先警告它给我页面,第二个解析错误,错误是:Uncaught TypeError:无法读取未定义的属性'firstParam'

我想在args中传入一个这样的字符串:

public String MyMethod() {
    RequestContext context = RequestContext.getCurrentInstance();  
    context.addCallbackParam("firstParam", "my string");
      return "";
}
Run Code Online (Sandbox Code Playgroud)

并使用javascript访问它args.firstParam.

该方法被调用,(我有一些工作的打印屏幕.)

我必须尝试这种方式,而不是将文本设置为

<h:outputText id="myText" escape="false" rendered="true"
            value="#{homeController.property}" />
Run Code Online (Sandbox Code Playgroud)

然后得到这个元素的innerHTML,因为我将使用innerHTML获得的内容与bean中的字符串变量不同.这种方法有效但不是我想要的.我想知道为什么args对象是未定义的,或者我怎样才能从javascript中管理bean属性.谢谢.

javascript ajax primefaces

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

使用CORS过滤器的交叉原始请求

我正在尝试将来自AngularJS 1.3应用程序的跨源请求发送到REST服务.虽然我启用了CORS过滤器,但我收到了403 Forbidden响应.这是请求(从chrome dev工具复制粘贴).在IE 9上它似乎工作.我在Chrome和Firefox上收到403错误代码.

Remote Address:127.0.0.1:8080
Request URL:http://localhost:8080/<path>
Request Method:OPTIONS
Status Code:403 Forbidden
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en,ro;q=0.8,en-US;q=0.6,en-GB;q=0.4
Access-Control-Request-Headers:x-auth-token, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:localhost:8080
Origin:http://localhost:9000
Referer:http://localhost:9000/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, ike Gecko) Chrome/40.0.2214.111 Safari/537.36
Response Headersview source
Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:Origin, Accept, x-auth-token, Content-Type,        
Access-Control-Request-Method, Access-Control-Request-Headers
Access-Control-Allow-Methods:POST, GET, HEAD, OPTIONS
Access-Control-Allow-Origin:http://localhost:9000
Content-Length:0
Content-Type:text/plain
Date:Tue, 17 Feb 2015 07:11:24 GMT
Server:Apache-Coyote/1.1
Run Code Online (Sandbox Code Playgroud)

网址没问题.如果我直接将其粘贴到浏览器中就可以了.

交叉原始身份验证有效:

Remote Address:127.0.0.1:8080
Request        
URL:http://localhost:8080/<serviceName>/webapi/authentication/authenticate
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, …
Run Code Online (Sandbox Code Playgroud)

ajax rest cross-domain cors angularjs

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