Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
88892845
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
88892845
编写于
11月 04, 2011
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SPR-8801 Set ignoreDefaultModelOnRedirect=false in MVC namespace and Java config.
上级
cd2fee03
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
36 addition
and
19 deletion
+36
-19
build-spring-framework/resources/changelog.txt
build-spring-framework/resources/changelog.txt
+1
-0
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
.../servlet/config/AnnotationDrivenBeanDefinitionParser.java
+5
-2
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
...servlet/config/annotation/WebMvcConfigurationSupport.java
+0
-1
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
...t/mvc/method/annotation/RequestMappingHandlerAdapter.java
+10
-10
org.springframework.web.servlet/src/main/resources/org/springframework/web/servlet/config/spring-mvc-3.1.xsd
...org/springframework/web/servlet/config/spring-mvc-3.1.xsd
+11
-0
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java
...let/config/AnnotationDrivenBeanDefinitionParserTests.java
+1
-1
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java
...springframework/web/servlet/config/MvcNamespaceTests.java
+5
-2
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java
...et/config/annotation/WebMvcConfigurationSupportTests.java
+1
-1
org.springframework.web.servlet/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator.xml
...mework/web/servlet/config/mvc-config-custom-validator.xml
+2
-2
未找到文件。
build-spring-framework/resources/changelog.txt
浏览文件 @
88892845
...
...
@@ -20,6 +20,7 @@ Changes in version 3.1 RC2 (2011-11-15)
* Fix issue in SimpleMappingExceptionResolver causing exception when setting "statusCodes" property
* The Form input tag allows type values other than "text" such as HTML5-specific types.
* The Form hidden tag supports "disabled" attribute
* Add ignoreDefaultModelOnRedirect attribute to <mvc:annotation-driven/>
Changes in version 3.1 RC1 (2011-10-11)
---------------------------------------
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
浏览文件 @
88892845
...
...
@@ -158,13 +158,16 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
ManagedList
<?>
messageConverters
=
getMessageConverters
(
element
,
source
,
parserContext
);
ManagedList
<?>
argumentResolvers
=
getArgumentResolvers
(
element
,
source
,
parserContext
);
ManagedList
<?>
returnValueHandlers
=
getReturnValueHandlers
(
element
,
source
,
parserContext
);
RootBeanDefinition
methodAdapterDef
=
new
RootBeanDefinition
(
RequestMappingHandlerAdapter
.
class
);
methodAdapterDef
.
setSource
(
source
);
methodAdapterDef
.
setRole
(
BeanDefinition
.
ROLE_INFRASTRUCTURE
);
methodAdapterDef
.
getPropertyValues
().
add
(
"webBindingInitializer"
,
bindingDef
);
methodAdapterDef
.
getPropertyValues
().
add
(
"messageConverters"
,
messageConverters
);
methodAdapterDef
.
getPropertyValues
().
add
(
"ignoreDefaultModelOnRedirect"
,
true
);
if
(
element
.
hasAttribute
(
"ignoreDefaultModelOnRedirect"
))
{
Boolean
ignoreDefaultModel
=
Boolean
.
valueOf
(
element
.
getAttribute
(
"ignoreDefaultModelOnRedirect"
));
methodAdapterDef
.
getPropertyValues
().
add
(
"ignoreDefaultModelOnRedirect"
,
ignoreDefaultModel
);
}
if
(
argumentResolvers
!=
null
)
{
methodAdapterDef
.
getPropertyValues
().
add
(
"customArgumentResolvers"
,
argumentResolvers
);
}
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
浏览文件 @
88892845
...
...
@@ -291,7 +291,6 @@ public abstract class WebMvcConfigurationSupport implements ApplicationContextAw
adapter
.
setWebBindingInitializer
(
webBindingInitializer
);
adapter
.
setCustomArgumentResolvers
(
argumentResolvers
);
adapter
.
setCustomReturnValueHandlers
(
returnValueHandlers
);
adapter
.
setIgnoreDefaultModelOnRedirect
(
true
);
return
adapter
;
}
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
浏览文件 @
88892845
...
...
@@ -40,7 +40,6 @@ import org.springframework.http.converter.HttpMessageConverter;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.http.converter.xml.SourceHttpMessageConverter
;
import
org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ReflectionUtils.MethodFilter
;
...
...
@@ -372,16 +371,17 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter i
}
/**
*
A controller can use the "default" {@link Model} in rendering and
* re
direct scenarios. Alternatively, it can use {@link RedirectAttributes}
*
to provide attributes for a redirect scenario.
*
<p>When this flag is set to {@code true}, the "default" model is never
*
used in a redirect even if the controller method doesn't explicitly
*
declare a RedirectAttributes argument.
*
<p>When set to {@code false}, the "default" model may be used in a
*
redirect if the controller method doesn't explicitly
declare a
*
By default the content of the "default" model is used both during
* re
ndering and redirect scenarios. Alternatively a controller method
*
can declare a {@link RedirectAttributes} argument and use it to provide
*
attributes for a redirect.
*
<p>Setting this flag to {@code true} guarantees the "default" model is
*
never used in a redirect scenario even if a RedirectAttributes argument
*
is not declared. Setting it to {@code false} means the "default" model
*
may be used in a redirect if the controller method doesn't
declare a
* RedirectAttributes argument.
* <p>The default setting is {@code false}.
* <p>The default setting is {@code false} but new applications should
* consider setting it to {@code true}.
* @see RedirectAttributes
*/
public
void
setIgnoreDefaultModelOnRedirect
(
boolean
ignoreDefaultModelOnRedirect
)
{
...
...
org.springframework.web.servlet/src/main/resources/org/springframework/web/servlet/config/spring-mvc-3.1.xsd
浏览文件 @
88892845
...
...
@@ -134,6 +134,17 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute
name=
"ignoreDefaultModelOnRedirect"
type=
"xsd:boolean"
>
<xsd:annotation>
<xsd:documentation>
<![CDATA[
By default the content of the "default" model is used both during rendering and redirect scenarios.
Alternatively a controller method can declare a RedirectAttributes argument and use it to provide attributes for a redirect.
Setting this flag to true ensures the "default" model is never used in a redirect scenario even if a RedirectAttributes argument is not declared.
Setting it to false means the "default" model may be used in a redirect if the controller method doesn't declare a RedirectAttributes argument.
The default setting is false but new applications should consider setting it to true.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java
浏览文件 @
88892845
...
...
@@ -67,7 +67,7 @@ public class AnnotationDrivenBeanDefinitionParserTests {
MessageCodesResolver
resolver
=
((
ConfigurableWebBindingInitializer
)
initializer
).
getMessageCodesResolver
();
assertNotNull
(
resolver
);
assertEquals
(
TestMessageCodesResolver
.
class
,
resolver
.
getClass
());
assertEquals
(
tru
e
,
new
DirectFieldAccessor
(
adapter
).
getPropertyValue
(
"ignoreDefaultModelOnRedirect"
));
assertEquals
(
fals
e
,
new
DirectFieldAccessor
(
adapter
).
getPropertyValue
(
"ignoreDefaultModelOnRedirect"
));
}
@Test
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java
浏览文件 @
88892845
...
...
@@ -34,6 +34,7 @@ import javax.validation.constraints.NotNull;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.beans.DirectFieldAccessor
;
import
org.springframework.beans.TypeMismatchException
;
import
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
;
import
org.springframework.context.i18n.LocaleContextHolder
;
...
...
@@ -109,6 +110,7 @@ public class MvcNamespaceTests {
RequestMappingHandlerAdapter
adapter
=
appContext
.
getBean
(
RequestMappingHandlerAdapter
.
class
);
assertNotNull
(
adapter
);
assertEquals
(
false
,
new
DirectFieldAccessor
(
adapter
).
getPropertyValue
(
"ignoreDefaultModelOnRedirect"
));
List
<
HttpMessageConverter
<?>>
messageConverters
=
adapter
.
getMessageConverters
();
assertTrue
(
messageConverters
.
size
()
>
0
);
...
...
@@ -166,6 +168,7 @@ public class MvcNamespaceTests {
RequestMappingHandlerAdapter
adapter
=
appContext
.
getBean
(
RequestMappingHandlerAdapter
.
class
);
assertNotNull
(
adapter
);
assertEquals
(
true
,
new
DirectFieldAccessor
(
adapter
).
getPropertyValue
(
"ignoreDefaultModelOnRedirect"
));
// default web binding initializer behavior test
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
...
...
@@ -322,7 +325,7 @@ public class MvcNamespaceTests {
ThemeChangeInterceptor
interceptor2
=
(
ThemeChangeInterceptor
)
chain
.
getInterceptors
()[
2
];
assertEquals
(
"style"
,
interceptor2
.
getParamName
());
}
@Test
public
void
testViewControllers
()
throws
Exception
{
loadBeanDefinitions
(
"mvc-config-view-controllers.xml"
,
14
);
...
...
@@ -346,7 +349,7 @@ public class MvcNamespaceTests {
SimpleUrlHandlerMapping
mapping2
=
appContext
.
getBean
(
SimpleUrlHandlerMapping
.
class
);
assertNotNull
(
mapping2
);
SimpleControllerHandlerAdapter
adapter
=
appContext
.
getBean
(
SimpleControllerHandlerAdapter
.
class
);
assertNotNull
(
adapter
);
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java
浏览文件 @
88892845
...
...
@@ -150,7 +150,7 @@ public class WebMvcConfigurationSupportTests {
assertNotNull
(
validator
);
assertTrue
(
validator
instanceof
LocalValidatorFactoryBean
);
assertEquals
(
tru
e
,
new
DirectFieldAccessor
(
adapter
).
getPropertyValue
(
"ignoreDefaultModelOnRedirect"
));
assertEquals
(
fals
e
,
new
DirectFieldAccessor
(
adapter
).
getPropertyValue
(
"ignoreDefaultModelOnRedirect"
));
}
@Test
...
...
org.springframework.web.servlet/src/test/resources/org/springframework/web/servlet/config/mvc-config-custom-validator.xml
浏览文件 @
88892845
...
...
@@ -3,9 +3,9 @@
xmlns:mvc=
"http://www.springframework.org/schema/mvc"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.
0
.xsd"
>
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.
1
.xsd"
>
<mvc:annotation-driven
validator=
"validator"
/>
<mvc:annotation-driven
validator=
"validator"
ignoreDefaultModelOnRedirect=
"true"
/>
<bean
id=
"validator"
class=
"org.springframework.web.servlet.config.MvcNamespaceTests$TestValidator"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录