Java 为什么';更新();不重定向到';sox&x27;在SpringMVC3.0中使用@ModelAttribute?
目前,我只想测试从update方法到sox方法的重定向。但我却收到一个错误,抱怨缺少Java 为什么';更新();不重定向到';sox&x27;在SpringMVC3.0中使用@ModelAttribute?,java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,目前,我只想测试从update方法到sox方法的重定向。但我却收到一个错误,抱怨缺少“update.jsp” 我认为您的问题是update方法上的@model属性。试着这样做: @RequestMapping(value = "/sox/update", method = RequestMethod.POST) public final String update(HttpServletRequest request, @ModelAttribute("formWrapper
“update.jsp”
我认为您的问题是update方法上的@model属性。试着这样做:
@RequestMapping(value = "/sox/update", method = RequestMethod.POST)
public final String update(HttpServletRequest request,
@ModelAttribute("formWrapper") FormWrapper formWrapper,
BindingResult bindResult,
ModelMap model)
{
return "redirect:/sox";
}
将@ModelAttribute添加到方法时,spring将返回视为模型属性:
任何其他返回类型都被视为
是要创建的单个模型属性
使用
通过指定的属性名
@方法级别的ModelAttribute
(或基于属性名的默认值)
返回类型(类名)。这个
模型隐含地丰富了
命令对象和
@模型属性注释引用
数据访问器方法
查看Spring文档的15.3.2.8了解更多信息:(http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann modelattrib)向我们展示您的
web.xml
和Spring配置文件。我刚刚添加了web.xml、DispatcherServlet和应用程序上下文。如果你还需要什么,请告诉我。谢谢我很感激。
@RequestMapping(value = "/sox/update", method = RequestMethod.POST)
public final String update(HttpServletRequest request,
@ModelAttribute("formWrapper") FormWrapper formWrapper,
BindingResult bindResult,
ModelMap model)
{
return "redirect:/sox";
}