Spring 接受页面传过来的参数的方式
使用HttpServletRequest获取:
javascript:
var a=$("#a").val();
var b=$("#b").val();
var c=$("#c").val();
$.post("${base!}/list.html",{"A":a,"B":b,"C":c},function(data){
var list = "";
var obj = eval("(" + data + ")");
$.each(obj, function(index, val) {
list += ........
}
});
java: 使用HttpServletRequest获取。
@RequestMapping("/list.html")
public void list_title1(HttpServletRequest request,HttpServletResponse response)throws IOException {
String A= request.getParameter("A");
String B= request.getParameter("B");
String C= request.getParameter("C");
}
使用@RequestParam注解:
@RequestMapping("/list.html")
public String login(HttpServletRequest request, String name, @RequestParam("pass")String password) // 表单属性是pass,用变量password接收
{
......
}