[英]DWR 3 and Spring 4
I have a problem with DWR 3 and Spring 4 which drives me crazy. 我在DWR 3和Spring 4中遇到问题,这使我发疯。
There is a class that has 2 methods: 有一个类具有2个方法:
package xxx.dwr.services;
@RemoteProxy
public class UnitsService extends DwrSupport {
@RemoteMethod
public List<UnitTreeNode> searchTreeNodes(UnitTreeSearchQuery query) {
...
}
@RemoteMethod
public List<UnitTreeNode> getTreeNodes(String parentNodeId, String clientIdString,boolean searchInHistory) {
...
}
}
When I click on the menu to open the unit tree page the getTreeNodes is called and it works fine, I can see the tree. 当我在菜单上单击以打开单元树页面时,将调用getTreeNodes ,并且工作正常,我可以看到树。 The tree can be filtered and in this case the searchTreeNodes method should be called but all I can see in the browser is a javascript alert dialog saying 'Error'. 可以过滤树,在这种情况下,应该调用searchTreeNodes方法,但是我在浏览器中只能看到一个显示“错误”的JavaScript警报对话框。
In the browser's console I can see the following: 在浏览器的控制台中,我可以看到以下内容:
dwr.engine._debug @ engine.js:984
dwr.engine.defaultErrorHandler @ engine.js:215
(anonymous) @ engine.js:1121
logHandlerEx @ engine.js:2553
handleException @ engine.js:1107
(anonymous) @ VM1365:9
(anonymous) @ VM1365:10
dwr.engine._executeScript @ engine.js:720
stateChange @ engine.js:1791
batch.req.onreadystatechange @ engine.js:1664
Error: undefined, Error
Which is not a lot of information... 信息不多...
So I can call one method but not the other one in the same class! 因此,我可以在同一个类中调用一个方法,但不能调用另一个方法!
The data transfer objects are as follows (normal beans with getters and setters): 数据传输对象如下(带有getter和setter的普通bean):
package xxx.dwr.services.dto;
@DataTransferObject
public class UnitTreeNode {
....
}
package xxx.dwr.services.dto;
@DataTransferObject
public class UnitTreeSearchQuery {
private UnitTreeSearchQueryField field;
private String input;
private String clientId;
private boolean searchInHistory;
...
}
package xxx.dwr.services.dto;
@DataTransferObject(converter = EnumConverter.class)
public enum UnitTreeSearchQueryField {
EXTID,
DISPLAYNAME,
ABBRNAME,
NAME,
REMARKS,
LOCATION,
STATE
}
The relating servlet configuration: 相关的servlet配置:
<servlet>
<servlet-name>DwrServlet</servlet-nam1e>
<servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>allowScriptTagRemoting</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<!-- disabled due to reverse proxy setup -->
<param-name>crossDomainSessionSecurity</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<!-- suppress the about DWR url -->
<param-name>url:/about</param-name>
<param-value>null</param-value>
</init-param>
</servlet>
And from the context.xml 并从context.xml
<dwr:configuration/>
<dwr:annotation-scan base-package="xxx.dwr.services" scanDataTransferObject="true" scanRemoteProxy="true" />
So I am at a complete loss what can go wrong. 所以我完全不知所措。 The Spring config should be fine as I can call one of the method from the web app. Spring配置应该很好,因为我可以从Web应用程序中调用其中一种方法。
Could you please help me? 请你帮助我好吗?
Thanks, 谢谢,
V. V.
Not sure why but I couldn't send the parameter as an object. 不知道为什么,但是我无法将参数作为对象发送。 Now I do the following (passing simple parameters): 现在,我执行以下操作(传递简单参数):
@RemoteMethod
public List<UnitTreeNode> searchTreeNodes(String field, String input, String clientId, String searchInHistory) {
and it works. 而且有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.