无法在Spring应用程序中接收从另一个Java应用程序发送的表单数据 [英] Cannot receive form data in Spring application sent from another java application
本文介绍了无法在Spring应用程序中接收从另一个Java应用程序发送的表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将HTML表单从旧版Java应用程序发布到基于Spring的Java应用程序中,但是在那里无法接收到表单字段. 您能提供有关如何解决此问题的帮助吗? 注意:我将表单从tomcat 5.5发布到tomcat 6中的新Spring应用程序,尽管这两个容器都位于同一服务器中. 下面我给出了代码片段:
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> |
我在其中定义了检索表单数据的方法的Spring MVC Controller:
@RequestMapping(value = "/" , method = RequestMethod.POST)
public String getMethod(@RequestParam String id ,ModelMap model, HttpServletRequest request){
model.addAttribute("login", id);
return "index";
}
我在萤火虫中遇到的错误:
推荐答案
您不是从表单发送id参数,因此在表单内部您缺少类似
You're not sending the id param from the form, so inside your form you're missing something like
<input type="hidden" name="id" value='[SOME VALUE]'>
这篇关于无法在Spring应用程序中接收从另一个Java应用程序发送的表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文