gc00001
2012-11-23 10:03
浏览 207

关于dwr传javabean参数的问题

本人刚刚自学了dwr,按照网上的讲解测试了dwr返回值为javabean,list,map,String[],String都没问题,但是在测试带javabean参数的时候出问题了,老是返回Error,为此又看了很多视频讲解,但是始终没找到问题所在,百度百科上的讲解也是和我写的一样,求各位大神指点,下面是代码
java代码
public class dwrtest {
public String test3(User user){
return user.getUser();
}
}

User.java
public class User {
private String user;
private String password;
public User(String user, String password) {
super();
this.user = user;
this.password = password;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

}

dwr.xml
<?xml version="1.0" encoding="UTF-8"?>







 

web.xml
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

dwr.jsp


struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


dwr-invoker
DWR Servlet
Direct Web Remoter Servlet
<!-- org.directwebremoting.servlet.DwrServlet-->
uk.ltd.getahead.dwr.DWRServlet

debug
true


dwr-invoker
/dwr/*

jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">





<br> $(function(){</p> <p>$(&quot;#btn&quot;).click(function(){</p> <p>testClass.test3({user:&quot;tom&quot;,password:&quot;111&quot;},function(data){alert(data);});</p> <p>});</p> <p>});</p> <p>

<input type="button" name="btn" id="btn" value="点击"/>


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • droxy 2012-11-23 10:16
    已采纳

    你这个dwr.xml的配置有问题

    点赞 评论

相关推荐 更多相似问题