Spring MVC提交表单未找到错误404 [英] Spring mvc submit form not found error 404
本文介绍了Spring MVC提交表单未找到错误404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用spring mvc,并且已经创建了一个jsp页面.
I am using spring mvc and I have created a jsp page.
redmn.jsp
<form id="forma" name="forma" action="something" method="post" enctype="multipart/form-data" >
//some fields
<input type="submit" value="Valider" />
</form>
然后我创建了一个控制器来处理我的请求:
Then I have created one controller to handle my request:
@Controller
public class SecondController{
@RequestMapping(value="/something", method= RequestMethod.POST)
public String addRes( HttpServletRequest req,
BindingResult result,
ModelMap model,
@RequestParam("file") MultipartFile file){
// some treatements
return "redmn"
}
单击提交按钮时,出现404错误.请有人帮助解决此问题.
When I am clicking the submit button, I am getting 404 error. Please someone help to resolve this issue.
推荐答案
我认为您缺少上下文路径.为了获得正确的请求路径,您应该附加上下文路径.
I think you are missing context path. In order to get correct request path you should append context path.
如果您正在使用spring标签lib
if you are using spring tag lib
<spring:url var="something" value="/something"></spring:url>
如果您使用的是jstl
If you are using jstl
<c:url var="something" value="/something"/>
然后在您的表单标签中指定操作
and then in your form tag specify action
action="${something}"
这篇关于Spring MVC提交表单未找到错误404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文