내가 RedirectAttributes 내가 포스트 URL에 간단한 양식을 보내고있다 그리고 난에 전송있어 값을보고 싶다스프링 MVC 3.1 RedirectAttributes는
3.1-RELEASE 스프링 MVC의 기능을 구현하기 위해 노력하고있어 작동하지 않습니다 재 :
내 컨트롤러는 다음과 같습니다:
@Controller
public class DefaultController {
@RequestMapping(value="/index.html", method=RequestMethod.GET)
public ModelAndView indexView(){
ModelAndView mv = new ModelAndView("index");
return mv;
}
@RequestMapping(value="/greetings.action", method=RequestMethod.POST)
public ModelAndView startTask(@RequestParam("firstName") String firstName,RedirectAttributes redirectAttributes){
redirectAttributes.addFlashAttribute("redirectAttributes.firstName", firstName);
ModelAndView mv = new ModelAndView(new RedirectView("success.html"));
return mv;
}
@RequestMapping(value="/success.html", method=RequestMethod.GET)
public ModelAndView successView(){
ModelAndView mv = new ModelAndView("success");
return mv;
}
}
지금 내 서블릿 XML은 다음과 같습니다
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="com.vanilla.flashscope.controllers" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
내 문제는 success.html보기에서 redirectAttributes가 비어 있다는 것입니다.
<body>
<h5>${redirectAttributes.firstName} </h5>
</body>
아무 것도 인쇄하지 않습니다.
나는 똑같습니다. 해결책이 있다면 알려주세요. – YNChumak
예, 했어요. 내 커뮤니티 사이트에서 그것에 대해 몇 가지 의견을 썼습니다. 도움이되기를 바랍니다. http://goo.gl/Qbym2 –
Tks Danny. 나는 같은 문제를 반복했다. 열쇠는 ModelAndView가 아닌 문자열을 돌려주었습니다. 이상하게 보이지만 작동합니다. –