ajax运用dwr工具,从前台页面值传递到后台Java对象里面,再根据对象的结果返回到页面上来(回钦波个人总结)
ajax运用dwr工具,从前台页面值传递到后台Java对象里面,再根据对象的结果返回到页面上来(回钦波个人总结)
编辑 文章分类:Web前端
1.java类
public class DwrTest5 {
public boolean hasPermission(String name,int password){
if("huiqinbo".equals(name)&&password == 1){
System.out.println("name=="+name);
return true;
}
return false;
}
}
2.dwr.xml
<dwr><allow><create creator="new" javascript="test5"><param name="class" value="com.yezhong.oa.dwr.DwrTest5"></create></allow></dwr>
3.jsp页面
<script type="text/javascript" src="dwr/engine.js"></script><script type="text/javascript" src="dwr/util.js"></script><script type="text/javascript" src="dwr/interface/test5.js"></script><script type="text/javascript">
function test2(){
test5.hasPermission(
${"name"}.value,
${"permission"}.value,
function(data){
${"hp"}.checked=data;
}
);
}
</script>