DWR 传递对象--参数 DEMO
具体配置参考前几个DWR DEMO
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import = "com.dwr.UserBean" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'dwrTest2.jsp' starting page</title>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="<%=path %>/dwrjs/util.js"></script>
<script type="text/javascript" src="<%=path %>/dwrjs/engine.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/dwr/interface/testDwrService.js"></script>
<script type="text/javascript">
function showSelect(){
// test 定义一个对象
var data ={id:3,userName:DWRUtil.getValue('uid'),psw:DWRUtil.getValue('pid')};
//var data ={id:3,userName:"yonghuming",psw:"mima"};
alert(data);
testDwrService.passObject(data,function(result){
alert(result);
});
}
</script>
</head>
<body style="margin-left: 300px">
This is my JSP page. <br>
<form action="#" method="post" name="frm">
<input type="button" value="Button" onclick="showSelect()"/>
<input type="hidden" id="uid" value="用户名">
<input type="hidden" id="pid" value="密码">
</form>
</body>
</html>
// dwr 传递对象 passObject
public String passObject(UserBean user){
System.out.println(user.getId()+"" +
" "+user.getPsw()+" "+user.getUserName());
return "passObject";
}
<allow>
<create creator="new" javascript="testDwrService">
<param name="class" value="com.dwr.TestDwrService2" />
<include method="passObject" />
</create>
<convert converter="bean" match="com.dwr.UserBean">
<param name="include" value="id,userName,psw"></param>
</convert>
</allow>