我正在尝试将 HTML 表单从遗留 java 应用程序发布到基于 Spring 的 java 应用程序。但是无法在那里接收到表单字段。 你能帮忙解决这个问题吗? 注意:我将表单从 tomcat 5.5 发布到 tomcat 6 中的新 Spring 应用程序,尽管这两个容器都位于同一台服务器中。 下面我给出了代码片段:
我从遗留应用程序发送的表单:
<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> |
我在其中定义了检索表单数据的方法的 Spring MVC Controller :
@RequestMapping(value = "/" , method = RequestMethod.POST)
public String getMethod(@RequestParam String id ,ModelMap model, HttpServletRequest request){
model.addAttribute("login", id);
return "index";
}
我在 Firebug 中遇到的错误:
最佳答案
您没有从表单发送 id 参数,所以在您的表单中您缺少类似的东西
<input type="hidden" name="id" value='[SOME VALUE]'>
关于java - 无法在 Spring 应用程序中接收从另一个 Java 应用程序发送的表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27549051/