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这个类)
/success.jsp
后台代码(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;
}
}