Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
152add37
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 搜索 >>
提交
152add37
编写于
8月 15, 2011
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SPR-6464 Add getInputFlashMap and getOutputFlashMap methods to RequestContextUtils
上级
f0db3d09
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
95 addition
and
88 deletion
+95
-88
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FlashMap.java
...c/main/java/org/springframework/web/servlet/FlashMap.java
+2
-2
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FlashMapManager.java
...java/org/springframework/web/servlet/FlashMapManager.java
+25
-30
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
...t/mvc/method/annotation/RequestMappingHandlerAdapter.java
+3
-5
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/support/DefaultFlashMapManager.java
...framework/web/servlet/support/DefaultFlashMapManager.java
+33
-31
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/support/RequestContextUtils.java
...ingframework/web/servlet/support/RequestContextUtils.java
+15
-4
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java
...va/org/springframework/web/servlet/view/RedirectView.java
+1
-1
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java
...tation/ServletAnnotationControllerHandlerMethodTests.java
+3
-3
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/support/DefaultFlashMapManagerTests.java
...work/web/servlet/support/DefaultFlashMapManagerTests.java
+12
-11
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java
...g/springframework/web/servlet/view/RedirectViewTests.java
+1
-1
未找到文件。
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FlashMap.java
浏览文件 @
152add37
...
...
@@ -41,11 +41,11 @@ public class FlashMap extends HashMap<String, Object> implements Comparable<Flas
private
final
Map
<
String
,
String
>
expectedRequestParameters
=
new
LinkedHashMap
<
String
,
String
>();
private
UrlPathHelper
urlPathHelper
=
new
UrlPathHelper
();
private
long
expirationStartTime
;
private
int
timeToLive
;
private
final
UrlPathHelper
urlPathHelper
=
new
UrlPathHelper
();
/**
* Provide a URL to identify the target request for this FlashMap.
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FlashMapManager.java
浏览文件 @
152add37
...
...
@@ -22,10 +22,12 @@ import org.springframework.web.servlet.support.RequestContextUtils;
/**
* A strategy interface for maintaining {@link FlashMap} instances in some
* underlying storage until the next request. The most common use case is
* a redirect. For example redirecting from a POST that creates a resource
* to the page that shows the created resource and passing along a
* success message that needs to be shown once only.
* underlying storage until the next request.
*
* <p>The most common use case for using flash storage is a redirect.
* For example creating a resource in a POST request and then redirecting
* to the page that shows the resource. Flash storage may be used to
* pass along a success message.
*
* @author Rossen Stoyanchev
* @since 3.1
...
...
@@ -33,48 +35,41 @@ import org.springframework.web.servlet.support.RequestContextUtils;
* @see FlashMap
*/
public
interface
FlashMapManager
{
/**
* Request attribute to hold the current request FlashMap.
* @see RequestContextUtils#getFlashMap
* Request attribute holding the read-only Map with flash attributes saved
* during the previous request.
* @see RequestContextUtils#getInputFlashMap(HttpServletRequest)
*/
public
static
final
String
CURRENT_FLASH_MAP_ATTRIBUTE
=
DispatcherServlet
.
class
.
getName
()
+
".CURREN
T_FLASH_MAP"
;
public
static
final
String
INPUT_FLASH_MAP_ATTRIBUTE
=
FlashMapManager
.
class
.
getName
()
+
".INPU
T_FLASH_MAP"
;
/**
* Request attribute to hold the FlashMap from the previous request.
* Access to the previous FlashMap should generally not be needed
* since its content is exposed as attributes of the current
* request. However, it may be useful to expose previous request
* flash attributes in other ways such as in the model of annotated
* controllers.
* Request attribute holding the {@link FlashMap} to add attributes to during
* the current request.
* @see RequestContextUtils#getOutputFlashMap(HttpServletRequest)
*/
public
static
final
String
PREVIOUS_FLASH_MAP_ATTRIBUTE
=
DispatcherServlet
.
class
.
getName
()
+
".PREVIOUS
_FLASH_MAP"
;
public
static
final
String
OUTPUT_FLASH_MAP_ATTRIBUTE
=
FlashMapManager
.
class
.
getName
()
+
".OUTPUT
_FLASH_MAP"
;
/**
* Perform flash storage tasks at the start of a new request:
* <ul>
* <li>Create a new FlashMap and make it available to the current request
* under the request attribute {@link #CURRENT_FLASH_MAP_ATTRIBUTE}.
* <li>Locate the FlashMap saved on the previous request and expose its
* contents as attributes in the current request, also exposing the
* previous FlashMap under {@link #PREVIOUS_FLASH_MAP_ATTRIBUTE}.
* <li>Check for and remove expired FlashMap instances.
* <li>Create a FlashMap and make it available under the request attribute
* {@link #OUTPUT_FLASH_MAP_ATTRIBUTE}.
* <li>Locate the FlashMap saved during the previous request and make it
* available under the request attribute {@link #INPUT_FLASH_MAP_ATTRIBUTE}.
* <li>Remove expired FlashMap instances.
* </ul>
*
* <p>If the {@link #CURRENT_FLASH_MAP_ATTRIBUTE} request attribute exists
* in the current request, this method should return "false" immediately.
* <p>If the {@link #OUTPUT_FLASH_MAP_ATTRIBUTE} request attribute exists
* return "false" immediately.
*
* @param request the current request
*
* @return "true" if flash storage tasks were performed; "false" otherwise.
*/
boolean
requestStarted
(
HttpServletRequest
request
);
/**
* Access the current FlashMap through the request attribute
* {@link #CURRENT_FLASH_MAP_ATTRIBUTE} and if it is not empty, save it
* in the underlying storage.
*
* Access the FlashMap with attributes added during the current request and
* if it is not empty, save it in the underlying storage.
* <p>If the call to {@link #requestStarted} returned "false", this
* method is not invoked.
*/
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
浏览文件 @
152add37
...
...
@@ -516,10 +516,8 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter i
ServletInvocableHandlerMethod
requestMappingMethod
=
createRequestMappingMethod
(
handlerMethod
);
ModelFactory
modelFactory
=
getModelFactory
(
handlerMethod
);
FlashMap
previousFlashMap
=
(
FlashMap
)
request
.
getAttribute
(
FlashMapManager
.
PREVIOUS_FLASH_MAP_ATTRIBUTE
);
ModelAndViewContainer
mavContainer
=
new
ModelAndViewContainer
();
mavContainer
.
addAllAttributes
(
previousFlashMap
);
mavContainer
.
addAllAttributes
(
RequestContextUtils
.
getInputFlashMap
(
request
)
);
modelFactory
.
initModel
(
webRequest
,
mavContainer
,
requestMappingMethod
);
SessionStatus
sessionStatus
=
new
SimpleSessionStatus
();
...
...
@@ -539,8 +537,8 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter i
}
if
(
model
instanceof
RedirectModel
)
{
RedirectModel
redirectModel
=
(
RedirectModel
)
model
;
FlashMap
currentFlashMap
=
RequestContextUtils
.
ge
tFlashMap
(
request
);
currentF
lashMap
.
putAll
(
redirectModel
.
getFlashAttributes
());
FlashMap
flashMap
=
RequestContextUtils
.
getOutpu
tFlashMap
(
request
);
f
lashMap
.
putAll
(
redirectModel
.
getFlashAttributes
());
}
return
mav
;
}
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/support/DefaultFlashMapManager.java
浏览文件 @
152add37
...
...
@@ -19,6 +19,7 @@ package org.springframework.web.servlet.support;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -29,7 +30,6 @@ import org.apache.commons.logging.LogFactory;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.servlet.FlashMap
;
import
org.springframework.web.servlet.FlashMapManager
;
import
org.springframework.web.util.WebUtils
;
/**
* A {@link FlashMapManager} that saves and retrieves FlashMap instances in the
...
...
@@ -58,48 +58,34 @@ public class DefaultFlashMapManager implements FlashMapManager {
/**
* {@inheritDoc}
*
* <p>This method never creates an HTTP session. The
current FlashMap is
*
exposed as a request attribute only and is not saved in the session
*
until {@link #requestCompleted}
.
* <p>This method never creates an HTTP session. The
new FlashMap created
*
for the current request is exposed as a request attribute only and is
*
not saved in the session until {@link #requestCompleted} is called
.
*/
public
boolean
requestStarted
(
HttpServletRequest
request
)
{
if
(
request
.
getAttribute
(
CURREN
T_FLASH_MAP_ATTRIBUTE
)
!=
null
)
{
if
(
request
.
getAttribute
(
OUTPU
T_FLASH_MAP_ATTRIBUTE
)
!=
null
)
{
return
false
;
}
FlashMap
curren
tFlashMap
=
new
FlashMap
();
request
.
setAttribute
(
CURRENT_FLASH_MAP_ATTRIBUTE
,
curren
tFlashMap
);
FlashMap
outpu
tFlashMap
=
new
FlashMap
();
request
.
setAttribute
(
OUTPUT_FLASH_MAP_ATTRIBUTE
,
outpu
tFlashMap
);
FlashMap
previousFlashMap
=
lookupPreviousFlashMap
(
request
);
if
(
previousFlashMap
!=
null
)
{
WebUtils
.
exposeRequestAttributes
(
request
,
previousFlashMap
);
request
.
setAttribute
(
PREVIOUS_FLASH_MAP_ATTRIBUTE
,
previousFlashMap
);
Map
<
String
,
?>
inputFlashMap
=
getFlashMap
(
request
);
if
(
inputFlashMap
!=
null
)
{
request
.
setAttribute
(
INPUT_FLASH_MAP_ATTRIBUTE
,
inputFlashMap
);
}
// Remove expired flash maps
List
<
FlashMap
>
allMaps
=
retrieveFlashMaps
(
request
,
false
);
if
(
allMaps
!=
null
&&
!
allMaps
.
isEmpty
())
{
List
<
FlashMap
>
expiredMaps
=
new
ArrayList
<
FlashMap
>();
for
(
FlashMap
flashMap
:
allMaps
)
{
if
(
flashMap
.
isExpired
())
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Removing expired FlashMap: "
+
flashMap
);
}
expiredMaps
.
add
(
flashMap
);
}
}
allMaps
.
removeAll
(
expiredMaps
);
}
removeExpiredFlashMaps
(
request
);
return
true
;
}
/**
* Return the
FlashMap from the previous request
.
* Return the
flash attributes saved during the previous request if any
.
*
* @return
the FlashMap from the previous request; or {@code null} if none
.
* @return
a read-only Map; or {@code null} if not found
.
*/
private
FlashMap
lookupPrevious
FlashMap
(
HttpServletRequest
request
)
{
private
Map
<
String
,
?>
get
FlashMap
(
HttpServletRequest
request
)
{
List
<
FlashMap
>
allMaps
=
retrieveFlashMaps
(
request
,
false
);
if
(
CollectionUtils
.
isEmpty
(
allMaps
))
{
return
null
;
...
...
@@ -123,7 +109,7 @@ public class DefaultFlashMapManager implements FlashMapManager {
Collections
.
sort
(
matches
);
FlashMap
match
=
matches
.
remove
(
0
);
allMaps
.
remove
(
match
);
return
match
;
return
Collections
.
unmodifiableMap
(
match
)
;
}
return
null
;
...
...
@@ -156,16 +142,32 @@ public class DefaultFlashMapManager implements FlashMapManager {
return
allMaps
;
}
private
void
removeExpiredFlashMaps
(
HttpServletRequest
request
)
{
List
<
FlashMap
>
allMaps
=
retrieveFlashMaps
(
request
,
false
);
if
(
allMaps
!=
null
&&
!
allMaps
.
isEmpty
())
{
List
<
FlashMap
>
expiredMaps
=
new
ArrayList
<
FlashMap
>();
for
(
FlashMap
flashMap
:
allMaps
)
{
if
(
flashMap
.
isExpired
())
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Removing expired FlashMap: "
+
flashMap
);
}
expiredMaps
.
add
(
flashMap
);
}
}
allMaps
.
removeAll
(
expiredMaps
);
}
}
/**
* {@inheritDoc}
*
* <p>The HTTP session is not created if the current FlashMap instance is empty.
*/
public
void
requestCompleted
(
HttpServletRequest
request
)
{
FlashMap
flashMap
=
(
FlashMap
)
request
.
getAttribute
(
CURREN
T_FLASH_MAP_ATTRIBUTE
);
FlashMap
flashMap
=
(
FlashMap
)
request
.
getAttribute
(
OUTPU
T_FLASH_MAP_ATTRIBUTE
);
if
(
flashMap
==
null
)
{
throw
new
IllegalStateException
(
"Did not find a FlashMap exposed as the request attribute "
+
CURREN
T_FLASH_MAP_ATTRIBUTE
);
"Did not find a FlashMap exposed as the request attribute "
+
OUTPU
T_FLASH_MAP_ATTRIBUTE
);
}
if
(!
flashMap
.
isEmpty
())
{
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/support/RequestContextUtils.java
浏览文件 @
152add37
...
...
@@ -17,6 +17,7 @@
package
org.springframework.web.servlet.support
;
import
java.util.Locale
;
import
java.util.Map
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletRequest
;
...
...
@@ -27,8 +28,8 @@ import org.springframework.ui.context.ThemeSource;
import
org.springframework.web.context.WebApplicationContext
;
import
org.springframework.web.context.support.WebApplicationContextUtils
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.FlashMapManager
;
import
org.springframework.web.servlet.FlashMap
;
import
org.springframework.web.servlet.FlashMapManager
;
import
org.springframework.web.servlet.LocaleResolver
;
import
org.springframework.web.servlet.ThemeResolver
;
...
...
@@ -156,12 +157,22 @@ public abstract class RequestContextUtils {
}
/**
* Retrieves the flash map to use for the current request.
* Return a read-only Map with flash attributes saved during the previous request.
* @param request the current request
* @return a read-only Map, or {@code null}
*/
@SuppressWarnings
(
"unchecked"
)
public
static
Map
<
String
,
?>
getInputFlashMap
(
HttpServletRequest
request
)
{
return
(
Map
<
String
,
?>)
request
.
getAttribute
(
FlashMapManager
.
INPUT_FLASH_MAP_ATTRIBUTE
);
}
/**
* Return a FlashMap to add attributes to during the current request.
* @param request current HTTP request
* @return the flash map for the current request; never {@code null}.
*/
public
static
FlashMap
getFlashMap
(
HttpServletRequest
request
)
{
return
(
FlashMap
)
request
.
getAttribute
(
FlashMapManager
.
CURREN
T_FLASH_MAP_ATTRIBUTE
);
public
static
FlashMap
get
Output
FlashMap
(
HttpServletRequest
request
)
{
return
(
FlashMap
)
request
.
getAttribute
(
FlashMapManager
.
OUTPU
T_FLASH_MAP_ATTRIBUTE
);
}
}
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/RedirectView.java
浏览文件 @
152add37
...
...
@@ -262,7 +262,7 @@ public class RedirectView extends AbstractUrlBasedView {
model
=
removeKeys
(
model
,
uriTemplate
.
getVariableNames
());
}
FlashMap
flashMap
=
RequestContextUtils
.
getFlashMap
(
request
);
FlashMap
flashMap
=
RequestContextUtils
.
get
Output
FlashMap
(
request
);
if
(!
CollectionUtils
.
isEmpty
(
flashMap
))
{
flashMap
.
setExpectedRequestUri
(
request
,
targetUrl
.
toString
());
}
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java
浏览文件 @
152add37
...
...
@@ -1469,7 +1469,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
assertEquals
(
200
,
response
.
getStatus
());
assertEquals
(
"messages/new"
,
response
.
getForwardedUrl
());
assertTrue
(
RequestContextUtils
.
getFlashMap
(
request
).
isEmpty
());
assertTrue
(
RequestContextUtils
.
get
Output
FlashMap
(
request
).
isEmpty
());
// POST -> success
request
=
new
MockHttpServletRequest
(
"POST"
,
"/messages"
);
...
...
@@ -1480,7 +1480,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
assertEquals
(
200
,
response
.
getStatus
());
assertEquals
(
"/messages/1?name=value"
,
response
.
getRedirectedUrl
());
assertEquals
(
"yay!"
,
RequestContextUtils
.
getFlashMap
(
request
).
get
(
"successMessage"
));
assertEquals
(
"yay!"
,
RequestContextUtils
.
get
Output
FlashMap
(
request
).
get
(
"successMessage"
));
// GET after POST
request
=
new
MockHttpServletRequest
(
"GET"
,
"/messages/1"
);
...
...
@@ -1491,7 +1491,7 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl
assertEquals
(
200
,
response
.
getStatus
());
assertEquals
(
"Got: yay!"
,
response
.
getContentAsString
());
assertTrue
(
RequestContextUtils
.
getFlashMap
(
request
).
isEmpty
());
assertTrue
(
RequestContextUtils
.
get
Output
FlashMap
(
request
).
isEmpty
());
}
/*
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/support/DefaultFlashMapManagerTests.java
浏览文件 @
152add37
...
...
@@ -54,7 +54,7 @@ public class DefaultFlashMapManagerTests {
boolean
initialized
=
this
.
flashMapManager
.
requestStarted
(
this
.
request
);
assertTrue
(
"Current FlashMap not initialized on first call"
,
initialized
);
assertNotNull
(
"Current FlashMap not found"
,
RequestContextUtils
.
getFlashMap
(
request
));
assertNotNull
(
"Current FlashMap not found"
,
RequestContextUtils
.
get
Output
FlashMap
(
request
));
initialized
=
this
.
flashMapManager
.
requestStarted
(
this
.
request
);
...
...
@@ -62,38 +62,39 @@ public class DefaultFlashMapManagerTests {
}
@Test
public
void
lookup
Previous
FlashMap
()
{
public
void
lookup
Input
FlashMap
()
{
FlashMap
flashMap
=
new
FlashMap
();
flashMap
.
put
(
"key"
,
"value"
);
List
<
FlashMap
>
allMaps
=
createFlashMapsSessionAttribute
();
allMaps
.
add
(
flashMap
);
this
.
flashMapManager
.
requestStarted
(
this
.
request
);
assert
Same
(
flashMap
,
request
.
getAttribute
(
DefaultFlashMapManager
.
PREVIOUS
_FLASH_MAP_ATTRIBUTE
));
assertEquals
(
"
Previous
FlashMap should have been removed"
,
0
,
allMaps
.
size
());
assert
Equals
(
flashMap
,
request
.
getAttribute
(
DefaultFlashMapManager
.
INPUT
_FLASH_MAP_ATTRIBUTE
));
assertEquals
(
"
Input
FlashMap should have been removed"
,
0
,
allMaps
.
size
());
}
@Test
public
void
lookup
Previous
FlashMapExpectedUrlPath
()
{
public
void
lookup
Input
FlashMapExpectedUrlPath
()
{
FlashMap
emptyFlashMap
=
new
FlashMap
();
FlashMap
oneFlashMap
=
new
FlashMap
();
oneFlashMap
.
setExpectedRequestUri
(
null
,
"/one"
);
FlashMap
oneOther
FlashMap
=
new
FlashMap
();
oneOtherFlashMap
.
setExpectedRequestUri
(
null
,
"/one/other
"
);
FlashMap
second
FlashMap
=
new
FlashMap
();
secondFlashMap
.
setExpectedRequestUri
(
null
,
"/one/two
"
);
List
<
FlashMap
>
allMaps
=
createFlashMapsSessionAttribute
();
allMaps
.
add
(
emptyFlashMap
);
allMaps
.
add
(
oneFlashMap
);
allMaps
.
add
(
oneOther
FlashMap
);
allMaps
.
add
(
second
FlashMap
);
Collections
.
shuffle
(
allMaps
);
this
.
request
.
setRequestURI
(
"/one"
);
this
.
flashMapManager
.
requestStarted
(
this
.
request
);
assert
Same
(
oneFlashMap
,
request
.
getAttribute
(
DefaultFlashMapManager
.
PREVIOUS
_FLASH_MAP_ATTRIBUTE
));
assert
Equals
(
oneFlashMap
,
request
.
getAttribute
(
DefaultFlashMapManager
.
INPUT
_FLASH_MAP_ATTRIBUTE
));
}
@Test
...
...
@@ -116,7 +117,7 @@ public class DefaultFlashMapManagerTests {
public
void
saveFlashMap
()
throws
InterruptedException
{
FlashMap
flashMap
=
new
FlashMap
();
flashMap
.
put
(
"name"
,
"value"
);
request
.
setAttribute
(
DefaultFlashMapManager
.
CURREN
T_FLASH_MAP_ATTRIBUTE
,
flashMap
);
request
.
setAttribute
(
DefaultFlashMapManager
.
OUTPU
T_FLASH_MAP_ATTRIBUTE
,
flashMap
);
this
.
flashMapManager
.
setFlashMapTimeout
(
0
);
this
.
flashMapManager
.
requestCompleted
(
this
.
request
);
...
...
@@ -132,7 +133,7 @@ public class DefaultFlashMapManagerTests {
@Test
public
void
saveFlashMapIsEmpty
()
throws
InterruptedException
{
request
.
setAttribute
(
DefaultFlashMapManager
.
CURREN
T_FLASH_MAP_ATTRIBUTE
,
new
FlashMap
());
request
.
setAttribute
(
DefaultFlashMapManager
.
OUTPU
T_FLASH_MAP_ATTRIBUTE
,
new
FlashMap
());
this
.
flashMapManager
.
requestCompleted
(
this
.
request
);
assertNull
(
getFlashMapsSessionAttribute
());
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java
浏览文件 @
152add37
...
...
@@ -115,7 +115,7 @@ public class RedirectViewTests {
MockHttpServletResponse
response
=
new
MockHttpServletResponse
();
FlashMap
flashMap
=
new
FlashMap
();
flashMap
.
put
(
"successMessage"
,
"yay!"
);
request
.
setAttribute
(
FlashMapManager
.
CURREN
T_FLASH_MAP_ATTRIBUTE
,
flashMap
);
request
.
setAttribute
(
FlashMapManager
.
OUTPU
T_FLASH_MAP_ATTRIBUTE
,
flashMap
);
rv
.
render
(
new
ModelMap
(
"id"
,
"1"
),
request
,
response
);
assertEquals
(
303
,
response
.
getStatus
());
assertEquals
(
"http://url.somewhere.com/path?id=1"
,
response
.
getHeader
(
"Location"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录