SpringMVC后台action取不到页面参数

试了好久,当页面输入框有name属性的时候,后台action可以取到参数值;但是页面输入框只有id属性,而没有name属性的时候,后台怎么也取不到参数值,无论是从request对象取还是直接绑定action方法列表,都取不到,求解?

action代码:
[code="java"]
@RequestMapping(value="/showSelf/add", method={RequestMethod.GET, RequestMethod.POST})
public String addContent(Long id, HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws Exception{
System.out.println("addContent!");
System.out.println("id is " + id);
String[] v = request.getParameterValues("id");
if(v != null){
System.out.println("getParameterValues is " + v[0]);
}
System.out.println("getParameter is " + request.getParameter("id"));
//HttpServletRequest request, HttpServletResponse response, ModelMap modelMap
// Enumeration pNames = request.getParameterNames();
// while(pNames.hasMoreElements()){
// System.out.println("paramName is " + pNames.nextElement());
// }
return "showSelf";
}
[/code]

页面代码:
[code="java"]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



xx



[/code]

以上代码action获取不到id为"id"的值,当页面中输入控件的id属性改为name时,后台可以取到

查看全部
wawxy2008
wawxy2008
2014/06/02 17:57
  • spring
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复