用JQuery.ajax方法,用post方式传两个int类型的参数给后台tomcat服务器...
发布网友
发布时间:2022-04-26 04:55
我来回答
共1个回答
热心网友
时间:2022-04-22 14:59
js代码
var param1 = 12;
var param2 = 24;
$.ajax({
type:"POST",
url:"ajax",
data:{'param1': param1, 'param2': param2},
success:function(data){
}
});
action配置(假如ajax url匹配com.test.Ajax这个类)
<action name="ajax" class="com.test.Ajax">
<result name="success">/success.jsp</result>
</action>
后台代码(Ajax类)
package com.test;
import com.opensymphony.xwork2.ActionSupport;
public class Ajax extends ActionSupport{
private Integer param1;
private Integer param2;
public void setParam1(Integer param1) {
this.param1 = param1;
}
public void setParam2(Integer param2) {
this.param2 = param2;
}
@Override
public String execute() throws Exception {
System.out.println(param1);
System.out.println(param2);
return SUCCESS;
}
}