I am trying to post an HTML form from a legacy java application to a Spring based java application.But the form field cannot be received there. can you please help on how to resolve the issue. Note: I am posting the form from tomcat 5.5 to the new Spring application in tomcat 6 though Both the containers reside in the same server. Below i have given the code snippets:
<form id ="user_Spring" method="POST" action="http://new_application_url/app-root/" ENCTYPE="application/x-www-form-urlencoded">
<input type="hidden" name="login" value='<%=user_Login %>'>
</form>
<a href="#" onclick="document.getElementById('user_Spring').submit();"><font color="red"></>New Application</font></a> |
@RequestMapping(value = "/" , method = RequestMethod.POST)
public String getMethod(@RequestParam String id ,ModelMap model, HttpServletRequest request){
model.addAttribute("login", id);
return "index";
}
您不是从表单发送id参数,因此在表单内部您缺少诸如
<input type="hidden" name="id" value='[SOME VALUE]'>
You are sending a form parameter named 'login' but you expect it to be magically bound to a method param named 'id'.
Rename the method parameter to 'login' or qualify it by specifying the HTTP param name:
@RequestMapping(value = "/" , method = RequestMethod.POST)
public String getMethod(@RequestParam("login") String id ,ModelMap model, HttpServletRequest request){
model.addAttribute("login", id);
return "index";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.