Spring MVC 3.1 RedirectAttributes ne fonctionne pas

Je suis en train de mettre en œuvre RedirectAttributes fonction de Spring MVC 3.1-Libération

Je suis envoyer un formulaire simple de Poster des URL et que vous aimeriez voir de la valeur, je suis de l'envoyer dans redirect:

mon Contrôleur ressemble à ceci:

@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;
    }
}

Maintenant, ma Servlet, XML ressemble à ceci:

<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>

Mon problème est que dans success.html vue redirectAttributes est vide.

<body>
<h5>${redirectAttributes.firstName} </h5> 
</body>

Imprime rien.

J'ai le même. Si vous obtenez la solution faites le moi savoir, s'il vous plaît.
Oui, je l'ai fait. J'ai écrit quelques pensées à ce sujet sur mon site de la communauté, j'espère qu'elle vous aidera. goo.gl/Qbym2
Tks Danny. J'ai été boucle de restauration aroung le même problème. La clé était de retourner une chaîne de caractères et non un ModelAndView, semble étrange, mais fonctionne.

OriginalL'auteur danny.lesnik | 2011-12-26