Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit 3b66b10

Browse files
committed
Merge pull request #89 from ivanzgb/master
SPR-12569
2 parents 0cb6d39 + 8aaa7aa commit 3b66b10

File tree

8 files changed

+459
-0
lines changed

8 files changed

+459
-0
lines changed

Diff for: SPR-12569/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### Running
2+
3+
Run with `mvn jetty:run` and visit:
4+
5+
* [http://localhost:8080/test1](http://localhost:8080/test1)
6+
* [http://localhost:8080/test2](http://localhost:8080/test2)
7+
* [http://localhost:8080/test3](http://localhost:8080/test3)
8+
* [http://localhost:8080/test4](http://localhost:8080/test4)
9+
10+
All should redirect to [http://localhost:8080/](http://localhost:8080/) and display 'Hello, World!', but test3 and test4 do not transfer the flash attribute.

Diff for: SPR-12569/pom.xml

+310
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.springframework.issues</groupId>
5+
<artifactId>SPR-12569</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Spring MVC Issue Reproduction Project</name>
8+
<packaging>war</packaging>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
13+
<java.version>1.6</java.version>
14+
<spring.version>4.1.3.RELEASE</spring.version>
15+
<slf4j.version>1.7.5</slf4j.version>
16+
17+
<jetty.version>9.1.2.v20140210</jetty.version>
18+
<cargo.container.id>tomcat7x</cargo.container.id>
19+
<cargo.container.url>
20+
http://www.eu.apache.org/dist/tomcat/tomcat-7/v7.0.57/bin/apache-tomcat-7.0.57.zip
21+
</cargo.container.url>
22+
<cargo.container.jvmargs>-Xms96m -Xmx512m -Djava.awt.headless=true</cargo.container.jvmargs>
23+
<cargo.jvm.debug.port>8000</cargo.jvm.debug.port>
24+
</properties>
25+
26+
<dependencies>
27+
<!-- Spring Framework -->
28+
<dependency>
29+
<groupId>org.springframework</groupId>
30+
<artifactId>spring-context</artifactId>
31+
<version>${spring.version}</version>
32+
<exclusions>
33+
<!-- Exclude Commons Logging in favor of SLF4j -->
34+
<exclusion>
35+
<groupId>commons-logging</groupId>
36+
<artifactId>commons-logging</artifactId>
37+
</exclusion>
38+
</exclusions>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework</groupId>
42+
<artifactId>spring-webmvc</artifactId>
43+
<version>${spring.version}</version>
44+
</dependency>
45+
46+
<!-- CGLIB, required for @Configuration usage -->
47+
<dependency>
48+
<groupId>cglib</groupId>
49+
<artifactId>cglib-nodep</artifactId>
50+
<version>2.2</version>
51+
</dependency>
52+
53+
<!-- Logging -->
54+
<dependency>
55+
<groupId>org.slf4j</groupId>
56+
<artifactId>slf4j-api</artifactId>
57+
<version>${slf4j.version}</version>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.slf4j</groupId>
61+
<artifactId>jcl-over-slf4j</artifactId>
62+
<version>${slf4j.version}</version>
63+
<scope>runtime</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.slf4j</groupId>
67+
<artifactId>slf4j-log4j12</artifactId>
68+
<version>${slf4j.version}</version>
69+
<scope>runtime</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>log4j</groupId>
73+
<artifactId>log4j</artifactId>
74+
<version>1.2.17</version>
75+
<scope>runtime</scope>
76+
</dependency>
77+
78+
<!-- Servlet API -->
79+
<dependency>
80+
<groupId>javax.servlet</groupId>
81+
<artifactId>servlet-api</artifactId>
82+
<version>2.5</version>
83+
<scope>provided</scope>
84+
</dependency>
85+
86+
<!-- JSP API and JSTL
87+
<dependency>
88+
<groupId>javax.servlet.jsp</groupId>
89+
<artifactId>jsp-api</artifactId>
90+
<version>2.1</version>
91+
<scope>provided</scope>
92+
</dependency>
93+
<dependency>
94+
<groupId>javax.servlet</groupId>
95+
<artifactId>jstl</artifactId>
96+
<version>1.2</version>
97+
</dependency>
98+
-->
99+
100+
<!-- Apache Tiles
101+
<dependency>
102+
<groupId>org.apache.tiles</groupId>
103+
<artifactId>tiles-jsp</artifactId>
104+
<version>2.1.3</version>
105+
<exclusions>
106+
<exclusion>
107+
<groupId>commons-logging</groupId>
108+
<artifactId>commons-logging-api</artifactId>
109+
</exclusion>
110+
</exclusions>
111+
</dependency>
112+
-->
113+
114+
<!-- JSR 303 with Hibernate Validator
115+
<dependency>
116+
<groupId>javax.validation</groupId>
117+
<artifactId>validation-api</artifactId>
118+
<version>1.0.0.GA</version>
119+
</dependency>
120+
<dependency>
121+
<groupId>org.hibernate</groupId>
122+
<artifactId>hibernate-validator</artifactId>
123+
<version>4.1.0.Final</version>
124+
</dependency>
125+
-->
126+
127+
<!-- Joda Time Library
128+
<dependency>
129+
<groupId>joda-time</groupId>
130+
<artifactId>joda-time</artifactId>
131+
<version>1.6.2</version>
132+
</dependency>
133+
<dependency>
134+
<groupId>joda-time</groupId>
135+
<artifactId>joda-time-jsptags</artifactId>
136+
<version>1.0.2</version>
137+
<scope>runtime</scope>
138+
</dependency>
139+
-->
140+
141+
<!-- Apache Commons File Upload
142+
<dependency>
143+
<groupId>commons-fileupload</groupId>
144+
<artifactId>commons-fileupload</artifactId>
145+
<version>1.2.2</version>
146+
</dependency>
147+
<dependency>
148+
<groupId>commons-io</groupId>
149+
<artifactId>commons-io</artifactId>
150+
<version>2.0.1</version>
151+
</dependency>
152+
-->
153+
154+
<!-- Jackson JSON Processor
155+
<dependency>
156+
<groupId>com.fasterxml.jackson.core</groupId>
157+
<artifactId>jackson-databind</artifactId>
158+
<version>2.4.3</version>
159+
</dependency>
160+
-->
161+
162+
<!-- Rome Atom+RSS
163+
<dependency>
164+
<groupId>rome</groupId>
165+
<artifactId>rome</artifactId>
166+
<version>1.0</version>
167+
</dependency>
168+
-->
169+
170+
<!-- Test -->
171+
<dependency>
172+
<groupId>junit</groupId>
173+
<artifactId>junit</artifactId>
174+
<version>4.11</version>
175+
<scope>test</scope>
176+
</dependency>
177+
</dependencies>
178+
179+
<build>
180+
<plugins>
181+
<plugin>
182+
<groupId>org.apache.maven.plugins</groupId>
183+
<artifactId>maven-compiler-plugin</artifactId>
184+
<version>2.5.1</version>
185+
<configuration>
186+
<source>${java.version}</source>
187+
<target>${java.version}</target>
188+
</configuration>
189+
</plugin>
190+
<plugin>
191+
<groupId>org.apache.maven.plugins</groupId>
192+
<artifactId>maven-dependency-plugin</artifactId>
193+
<version>2.8</version>
194+
<executions>
195+
<execution>
196+
<id>install</id>
197+
<phase>install</phase>
198+
<goals>
199+
<goal>sources</goal>
200+
</goals>
201+
</execution>
202+
</executions>
203+
</plugin>
204+
<plugin>
205+
<groupId>org.apache.maven.plugins</groupId>
206+
<artifactId>maven-eclipse-plugin</artifactId>
207+
<version>2.8</version>
208+
<configuration>
209+
<downloadSources>true</downloadSources>
210+
<downloadJavadocs>false</downloadJavadocs>
211+
<wtpversion>2.0</wtpversion>
212+
</configuration>
213+
</plugin>
214+
<plugin>
215+
<groupId>org.apache.maven.plugins</groupId>
216+
<artifactId>maven-surefire-plugin</artifactId>
217+
<version>2.12.4</version>
218+
<configuration>
219+
<includes>
220+
<include>**/*Tests.java</include>
221+
<include>**/*Test.java</include>
222+
</includes>
223+
<excludes>
224+
<exclude>**/*Abstract*.java</exclude>
225+
</excludes>
226+
</configuration>
227+
</plugin>
228+
<plugin>
229+
<groupId>org.eclipse.jetty</groupId>
230+
<artifactId>jetty-maven-plugin</artifactId>
231+
<version>${jetty.version}</version>
232+
</plugin>
233+
<plugin>
234+
<groupId>org.codehaus.cargo</groupId>
235+
<artifactId>cargo-maven2-plugin</artifactId>
236+
<version>1.4.7</version>
237+
<configuration>
238+
<configuration>
239+
<properties>
240+
<cargo.servlet.port>8080</cargo.servlet.port>
241+
<cargo.tomcat.ajp.port>1099</cargo.tomcat.ajp.port>
242+
<cargo.rmi.port>1099</cargo.rmi.port>
243+
<cargo.logging>medium</cargo.logging>
244+
<cargo.jvmargs>${cargo.container.jvmargs}</cargo.jvmargs>
245+
</properties>
246+
</configuration>
247+
<container>
248+
<containerId>${cargo.container.id}</containerId>
249+
<zipUrlInstaller>
250+
<url>${cargo.container.url}</url>
251+
</zipUrlInstaller>
252+
</container>
253+
</configuration>
254+
</plugin>
255+
</plugins>
256+
</build>
257+
258+
<profiles>
259+
<profile>
260+
<id>tomcat8</id>
261+
<properties>
262+
<cargo.container.id>tomcat8x</cargo.container.id>
263+
<cargo.container.url>
264+
http://www.eu.apache.org/dist/tomcat/tomcat-8/v8.0.15/bin/apache-tomcat-8.0.15.zip
265+
</cargo.container.url>
266+
</properties>
267+
</profile>
268+
<profile>
269+
<id>jetty8</id>
270+
<build>
271+
<plugins>
272+
<plugin>
273+
<groupId>org.codehaus.cargo</groupId>
274+
<artifactId>cargo-maven2-plugin</artifactId>
275+
<configuration>
276+
<container>
277+
<containerId>jetty8x</containerId>
278+
<type>embedded</type>
279+
</container>
280+
</configuration>
281+
</plugin>
282+
</plugins>
283+
</build>
284+
</profile>
285+
<profile>
286+
<id>debug</id>
287+
<properties>
288+
<cargo.container.jvmargs>
289+
-Xdebug
290+
-Xrunjdwp:transport=dt_socket,address=${cargo.jvm.debug.port},suspend=n,server=y
291+
-Xnoagent
292+
-Djava.compiler=NONE
293+
</cargo.container.jvmargs>
294+
</properties>
295+
</profile>
296+
</profiles>
297+
298+
<repositories>
299+
<repository>
300+
<id>spring-maven-snapshot</id>
301+
<name>Springframework Maven Snapshot Repository</name>
302+
<url>http://repo.spring.io/snapshot</url>
303+
<snapshots>
304+
<enabled>true</enabled>
305+
</snapshots>
306+
</repository>
307+
</repositories>
308+
309+
</project>
310+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.springframework.issues.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
8+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
10+
11+
@EnableWebMvc
12+
@ComponentScan(basePackages="org.springframework.issues")
13+
@Configuration
14+
public class WebConfig extends WebMvcConfigurerAdapter {
15+
16+
@Override
17+
public void addViewControllers(ViewControllerRegistry registry) {
18+
registry.addViewController("/").setViewName("home");
19+
}
20+
21+
@Bean
22+
public InternalResourceViewResolver viewResolver() {
23+
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
24+
viewResolver.setPrefix("/WEB-INF/views/");
25+
viewResolver.setSuffix(".jsp");
26+
return viewResolver;
27+
}
28+
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.springframework.issues.web;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.ModelMap;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.ResponseBody;
7+
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
8+
9+
@Controller
10+
public class TestController {
11+
12+
@RequestMapping("/")
13+
@ResponseBody
14+
String hello(ModelMap model) {
15+
String name = (String)model.getOrDefault("name", "???");
16+
return "Hello, " + name + "!";
17+
}
18+
19+
@RequestMapping("/test1") // OK
20+
String test1(RedirectAttributes redir) {
21+
redir.addFlashAttribute("name", "World");
22+
return "redirect:/";
23+
}
24+
25+
@RequestMapping("/test2") // OK
26+
String test2(RedirectAttributes redir) {
27+
redir.addFlashAttribute("name", "World");
28+
return "redirect:/?param=1";
29+
}
30+
31+
@RequestMapping("/test3") // NOT WORKING
32+
String test3(RedirectAttributes redir) {
33+
redir.addFlashAttribute("name", "World");
34+
return "redirect:/?param=1+2";
35+
}
36+
37+
@RequestMapping("/test4") // NOT WORKING
38+
String test4(RedirectAttributes redir) {
39+
redir.addFlashAttribute("name", "World");
40+
redir.addAttribute("param", "1 2");
41+
return "redirect:/";
42+
}
43+
44+
}

0 commit comments

Comments
 (0)