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

Commit 208a6cb

Browse files
committed
Issue project SPR-9239
1 parent 7b8508d commit 208a6cb

File tree

11 files changed

+394
-0
lines changed

11 files changed

+394
-0
lines changed

SPR-9239/pom.xml

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
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-9239</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Spring MVC Issue Reproduction Project</name>
8+
<packaging>war</packaging>
9+
10+
<properties>
11+
<java-version>1.6</java-version>
12+
<org.springframework-version>3.2.0.BUILD-SNAPSHOT</org.springframework-version>
13+
<org.slf4j-version>1.6.1</org.slf4j-version>
14+
</properties>
15+
16+
<dependencies>
17+
<!-- Spring Framework -->
18+
<dependency>
19+
<groupId>org.springframework</groupId>
20+
<artifactId>spring-context</artifactId>
21+
<version>${org.springframework-version}</version>
22+
<exclusions>
23+
<!-- Exclude Commons Logging in favor of SLF4j -->
24+
<exclusion>
25+
<groupId>commons-logging</groupId>
26+
<artifactId>commons-logging</artifactId>
27+
</exclusion>
28+
</exclusions>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework</groupId>
32+
<artifactId>spring-webmvc</artifactId>
33+
<version>${org.springframework-version}</version>
34+
</dependency>
35+
36+
<!-- Logging -->
37+
<dependency>
38+
<groupId>org.slf4j</groupId>
39+
<artifactId>slf4j-api</artifactId>
40+
<version>${org.slf4j-version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.slf4j</groupId>
44+
<artifactId>jcl-over-slf4j</artifactId>
45+
<version>${org.slf4j-version}</version>
46+
<scope>runtime</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.slf4j</groupId>
50+
<artifactId>slf4j-log4j12</artifactId>
51+
<version>${org.slf4j-version}</version>
52+
<scope>runtime</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>log4j</groupId>
56+
<artifactId>log4j</artifactId>
57+
<version>1.2.16</version>
58+
<scope>runtime</scope>
59+
</dependency>
60+
61+
<!-- Servlet API -->
62+
<dependency>
63+
<groupId>javax.servlet</groupId>
64+
<artifactId>servlet-api</artifactId>
65+
<version>2.5</version>
66+
<scope>provided</scope>
67+
</dependency>
68+
69+
<!-- JSP API and JSTL
70+
<dependency>
71+
<groupId>javax.servlet.jsp</groupId>
72+
<artifactId>jsp-api</artifactId>
73+
<version>2.1</version>
74+
<scope>provided</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>javax.servlet</groupId>
78+
<artifactId>jstl</artifactId>
79+
<version>1.2</version>
80+
</dependency>
81+
-->
82+
83+
<!-- Apache Tiles
84+
<dependency>
85+
<groupId>org.apache.tiles</groupId>
86+
<artifactId>tiles-jsp</artifactId>
87+
<version>2.1.3</version>
88+
<exclusions>
89+
<exclusion>
90+
<groupId>commons-logging</groupId>
91+
<artifactId>commons-logging-api</artifactId>
92+
</exclusion>
93+
</exclusions>
94+
</dependency>
95+
-->
96+
97+
<!-- JSR 303 with Hibernate Validator
98+
<dependency>
99+
<groupId>javax.validation</groupId>
100+
<artifactId>validation-api</artifactId>
101+
<version>1.0.0.GA</version>
102+
</dependency>
103+
<dependency>
104+
<groupId>org.hibernate</groupId>
105+
<artifactId>hibernate-validator</artifactId>
106+
<version>4.1.0.Final</version>
107+
</dependency>
108+
-->
109+
110+
<!-- Joda Time Library
111+
<dependency>
112+
<groupId>joda-time</groupId>
113+
<artifactId>joda-time</artifactId>
114+
<version>1.6.2</version>
115+
</dependency>
116+
<dependency>
117+
<groupId>joda-time</groupId>
118+
<artifactId>joda-time-jsptags</artifactId>
119+
<version>1.0.2</version>
120+
<scope>runtime</scope>
121+
</dependency>
122+
-->
123+
124+
<!-- Apache Commons File Upload
125+
<dependency>
126+
<groupId>commons-fileupload</groupId>
127+
<artifactId>commons-fileupload</artifactId>
128+
<version>1.2.2</version>
129+
</dependency>
130+
<dependency>
131+
<groupId>commons-io</groupId>
132+
<artifactId>commons-io</artifactId>
133+
<version>2.0.1</version>
134+
</dependency>
135+
-->
136+
137+
<!-- Jackson JSON Processor -->
138+
<dependency>
139+
<groupId>org.codehaus.jackson</groupId>
140+
<artifactId>jackson-mapper-asl</artifactId>
141+
<version>1.8.1</version>
142+
</dependency>
143+
144+
<!-- Rome Atom+RSS
145+
<dependency>
146+
<groupId>rome</groupId>
147+
<artifactId>rome</artifactId>
148+
<version>1.0</version>
149+
</dependency>
150+
-->
151+
152+
<!-- Test -->
153+
<dependency>
154+
<groupId>junit</groupId>
155+
<artifactId>junit</artifactId>
156+
<version>4.8</version>
157+
<scope>test</scope>
158+
</dependency>
159+
</dependencies>
160+
161+
<repositories>
162+
<repository>
163+
<id>spring-maven-snapshot</id>
164+
<name>Springframework Maven Snapshot Repository</name>
165+
<url>http://repo.springsource.org/snapshot</url>
166+
<snapshots>
167+
<enabled>true</enabled>
168+
</snapshots>
169+
</repository>
170+
</repositories>
171+
172+
<build>
173+
<plugins>
174+
<plugin>
175+
<artifactId>maven-compiler-plugin</artifactId>
176+
<configuration>
177+
<source>${java-version}</source>
178+
<target>${java-version}</target>
179+
</configuration>
180+
</plugin>
181+
<plugin>
182+
<groupId>org.apache.maven.plugins</groupId>
183+
<artifactId>maven-dependency-plugin</artifactId>
184+
<executions>
185+
<execution>
186+
<id>install</id>
187+
<phase>install</phase>
188+
<goals>
189+
<goal>sources</goal>
190+
</goals>
191+
</execution>
192+
</executions>
193+
</plugin>
194+
<plugin>
195+
<groupId>org.apache.maven.plugins</groupId>
196+
<artifactId>maven-eclipse-plugin</artifactId>
197+
<version>2.8</version>
198+
<configuration>
199+
<downloadSources>true</downloadSources>
200+
<downloadJavadocs>false</downloadJavadocs>
201+
<wtpversion>2.0</wtpversion>
202+
</configuration>
203+
</plugin>
204+
<plugin>
205+
<artifactId>maven-surefire-plugin</artifactId>
206+
<configuration>
207+
<includes>
208+
<include>**/*Tests.java</include>
209+
</includes>
210+
<excludes>
211+
<exclude>**/*Abstract*.java</exclude>
212+
</excludes>
213+
</configuration>
214+
</plugin>
215+
</plugins>
216+
</build>
217+
218+
</project>
219+

SPR-9239/src/main/java/org/springframework/issues/.gitignore

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.springframework.issues;
2+
3+
import javax.xml.bind.annotation.XmlRootElement;
4+
5+
@XmlRootElement
6+
public class MyBody {
7+
8+
private String name;
9+
10+
protected String getName() {
11+
return name;
12+
}
13+
14+
protected void setName(String name) {
15+
this.name = name;
16+
}
17+
18+
@Override
19+
public String toString() {
20+
return "MyBody [name=" + name + "]";
21+
}
22+
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.springframework.issues;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.util.MultiValueMap;
5+
import org.springframework.web.bind.annotation.RequestBody;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RequestMethod;
8+
import org.springframework.web.bind.annotation.ResponseBody;
9+
10+
@Controller
11+
public class TestController {
12+
13+
@RequestMapping(method = RequestMethod.POST, value = "/url", consumes="application/x-www-form-urlencoded")
14+
@ResponseBody
15+
public String method(@RequestBody(required=false) MultiValueMap<String, String> values) {
16+
return "Got [" + values + "]";
17+
}
18+
19+
@RequestMapping(method = RequestMethod.POST, value = "/url", consumes="application/json")
20+
@ResponseBody
21+
public String method(@RequestBody(required=false) MyBody myBody) {
22+
return "Got [" + myBody + "]";
23+
}
24+
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
log4j.rootCategory=INFO, stdout
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
6+
7+
log4j.category.org.springframework.web=DEBUG
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="
5+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
6+
7+
<!-- Root Context: defines shared resources visible to all other web components -->
8+
9+
</beans>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:mvc="http://www.springframework.org/schema/mvc"
5+
xmlns:context="http://www.springframework.org/schema/context"
6+
xsi:schemaLocation="
7+
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
8+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
9+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
10+
11+
<mvc:annotation-driven />
12+
13+
<mvc:view-controller path="/" view-name="home" />
14+
15+
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
16+
<property name="prefix" value="/WEB-INF/views/" />
17+
<property name="suffix" value=".jsp" />
18+
</bean>
19+
20+
<context:component-scan base-package="org.springframework.issues" />
21+
22+
</beans>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<title>Home</title>
7+
</head>
8+
<body>
9+
<h1>Home</h1>
10+
11+
<form id="saveForm" action="url" method="post">
12+
<button type="submit" name="save">Save</button>
13+
<p></p>
14+
</form>
15+
16+
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
17+
<script type="text/javascript">
18+
$(document).ready(function() {
19+
20+
$("#saveForm").submit(function() {
21+
var form = $(this);
22+
$.ajax({ type: "POST", url: 'url',
23+
24+
// contentType: "application/json",
25+
// data : '{ "name" : "Joe" }',
26+
27+
contentType: "application/x-www-form-urlencoded",
28+
data : 'foo=bar&fruit=apple',
29+
30+
dataType: "text",
31+
success: function(text) {
32+
$("p").replaceWith('<p>' + text + '</p>');
33+
},
34+
error: function(xhr) {
35+
$("p").replaceWith('<p>' + xhr.responseText + '</p>');
36+
}
37+
});
38+
return false;
39+
});
40+
41+
42+
});
43+
</script>
44+
45+
</body>
46+
</html>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
5+
6+
<context-param>
7+
<param-name>contextConfigLocation</param-name>
8+
<param-value>/WEB-INF/spring/root-context.xml</param-value>
9+
</context-param>
10+
11+
<listener>
12+
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
13+
</listener>
14+
15+
<servlet>
16+
<servlet-name>appServlet</servlet-name>
17+
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
18+
<init-param>
19+
<param-name>contextConfigLocation</param-name>
20+
<param-value>/WEB-INF/spring/servlet-context.xml</param-value>
21+
</init-param>
22+
<load-on-startup>1</load-on-startup>
23+
</servlet>
24+
25+
<servlet-mapping>
26+
<servlet-name>appServlet</servlet-name>
27+
<url-pattern>/</url-pattern>
28+
</servlet-mapping>
29+
30+
<!-- Disables Servlet Container welcome file handling. Needed for compatibility
31+
with Servlet 3.0 and Tomcat 7.0 -->
32+
<welcome-file-list>
33+
<welcome-file></welcome-file>
34+
</welcome-file-list>
35+
36+
</web-app>

SPR-9239/src/test/java/org/springframework/issues/.gitignore

Whitespace-only changes.

0 commit comments

Comments
 (0)