Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring MVC 3.1 RedirectAttributes is not working
    primarykey
    data
    text
    <p>I'm trying to implement RedirectAttributes feature in Spring MVC 3.1-Release</p> <p>I'm sending simple form to Post URL and would like to see the the value I'm sending in redirect:</p> <p>my Controller looks like this:</p> <pre><code>@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; } } </code></pre> <p>Now my Servlet XML looks like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;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"&gt; &lt;mvc:annotation-driven/&gt; &lt;context:component-scan base-package="com.vanilla.flashscope.controllers" /&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix"&gt; &lt;value&gt;/&lt;/value&gt; &lt;/property&gt; &lt;property name="suffix"&gt; &lt;value&gt;.jsp&lt;/value&gt; &lt;/property&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>My problem is that in success.html view redirectAttributes is empty.</p> <pre><code>&lt;body&gt; &lt;h5&gt;${redirectAttributes.firstName} &lt;/h5&gt; &lt;/body&gt; </code></pre> <p>Prints nothing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload