本文整理汇总了Java中org.springframework.web.servlet.support.SessionFlashMapManager类的典型用法代码示例。如果您正苦于以下问题:Java SessionFlashMapManager类的具体用法?Java SessionFlashMapManager怎么用?Java SessionFlashMapManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionFlashMapManager类属于org.springframework.web.servlet.support包,在下文中一共展示了SessionFlashMapManager类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerMvcSingletons
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
private void registerMvcSingletons(StubWebApplicationContext cxt) {
StandaloneConfiguration configuration = new StandaloneConfiguration();
RequestMappingHandlerMapping handlerMapping = configuration.requestMappingHandlerMapping();
handlerMapping.setServletContext(cxt.getServletContext());
handlerMapping.setApplicationContext(cxt);
cxt.addBean("requestMappingHandlerMapping", handlerMapping);
RequestMappingHandlerAdapter handlerAdapter = configuration.requestMappingHandlerAdapter();
handlerAdapter.setServletContext(cxt.getServletContext());
handlerAdapter.setApplicationContext(cxt);
handlerAdapter.afterPropertiesSet();
cxt.addBean("requestMappingHandlerAdapter", handlerAdapter);
cxt.addBean("handlerExceptionResolver", configuration.handlerExceptionResolver());
cxt.addBeans(initViewResolvers(cxt));
cxt.addBean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, this.localeResolver);
cxt.addBean(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, new FixedThemeResolver());
cxt.addBean(DispatcherServlet.REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, new DefaultRequestToViewNameTranslator());
this.flashMapManager = new SessionFlashMapManager();
cxt.addBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, this.flashMapManager);
}
示例2: setUp
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
@Before
public void setUp() {
this.request = new MockHttpServletRequest();
this.response = new MockHttpServletResponse();
this.request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
this.request.setAttribute(DispatcherServlet.FLASH_MAP_MANAGER_ATTRIBUTE, new SessionFlashMapManager());
}
示例3: http11
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
@Test
public void http11() throws Exception {
RedirectView rv = new RedirectView();
rv.setUrl("http://url.somewhere.com");
rv.setHttp10Compatible(false);
MockHttpServletRequest request = createRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
request.setAttribute(DispatcherServlet.FLASH_MAP_MANAGER_ATTRIBUTE, new SessionFlashMapManager());
rv.render(new HashMap<String, Object>(), request, response);
assertEquals(303, response.getStatus());
assertEquals("http://url.somewhere.com", response.getHeader("Location"));
}
示例4: registerMvcSingletons
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
private void registerMvcSingletons(StubWebApplicationContext wac) {
StandaloneConfiguration config = new StandaloneConfiguration();
config.setApplicationContext(wac);
wac.addBeans(this.controllerAdvice);
StaticRequestMappingHandlerMapping hm = config.getHandlerMapping();
hm.setServletContext(wac.getServletContext());
hm.setApplicationContext(wac);
hm.afterPropertiesSet();
hm.registerHandlers(this.controllers);
wac.addBean("requestMappingHandlerMapping", hm);
RequestMappingHandlerAdapter handlerAdapter = config.requestMappingHandlerAdapter();
handlerAdapter.setServletContext(wac.getServletContext());
handlerAdapter.setApplicationContext(wac);
handlerAdapter.afterPropertiesSet();
wac.addBean("requestMappingHandlerAdapter", handlerAdapter);
wac.addBean("handlerExceptionResolver", config.handlerExceptionResolver());
wac.addBeans(initViewResolvers(wac));
wac.addBean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, this.localeResolver);
wac.addBean(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, new FixedThemeResolver());
wac.addBean(DispatcherServlet.REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, new DefaultRequestToViewNameTranslator());
this.flashMapManager = new SessionFlashMapManager();
wac.addBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, this.flashMapManager);
}
示例5: flashAttribute
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
@Test
public void flashAttribute() {
this.builder.flashAttr("foo", "bar");
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
FlashMap flashMap = new SessionFlashMapManager().retrieveAndUpdate(request, null);
assertNotNull(flashMap);
assertEquals("bar", flashMap.get("foo"));
}
示例6: preHandle
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
Object flashMapObj = RequestContextUtils.getOutputFlashMap(request);
if (flashMapObj != null && !(flashMapObj instanceof FlashMap)) {
// we need to create a FlashMap using the webapp classLoader
FlashMap flashMapCopy = new FlashMap();
flashMapCopy.putAll((Map<? extends String, ?>) flashMapObj);
// then put it in the request
SessionFlashMapManager sessionFlashMapManager = new SessionFlashMapManager();
sessionFlashMapManager.saveOutputFlashMap(flashMapCopy, request, response);
}
return true;
}
示例7: flashAttribute
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
@Test
public void flashAttribute() throws Exception {
this.builder.flashAttr("foo", "bar");
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
FlashMap flashMap = new SessionFlashMapManager().retrieveAndUpdate(request, null);
assertNotNull(flashMap);
assertEquals("bar", flashMap.get("foo"));
}
示例8: createRequest
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
private MockHttpServletRequest createRequest() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
request.setAttribute(DispatcherServlet.FLASH_MAP_MANAGER_ATTRIBUTE, new SessionFlashMapManager());
return request;
}
示例9: doTest
import org.springframework.web.servlet.support.SessionFlashMapManager; //导入依赖的package包/类
private void doTest(final Map<String, ?> map, final String url, final boolean contextRelative,
final boolean exposeModelAttributes, String expectedUrlForEncoding) throws Exception {
class TestRedirectView extends RedirectView {
public boolean queryPropertiesCalled = false;
/**
* Test whether this callback method is called with correct args
*/
@Override
protected Map<String, Object> queryProperties(Map<String, Object> model) {
// They may not be the same model instance, but they're still equal
assertTrue("Map and model must be equal.", map.equals(model));
this.queryPropertiesCalled = true;
return super.queryProperties(model);
}
}
TestRedirectView rv = new TestRedirectView();
rv.setUrl(url);
rv.setContextRelative(contextRelative);
rv.setExposeModelAttributes(exposeModelAttributes);
HttpServletRequest request = mock(HttpServletRequest.class, "request");
if (exposeModelAttributes) {
given(request.getCharacterEncoding()).willReturn(WebUtils.DEFAULT_CHARACTER_ENCODING);
}
if (contextRelative) {
expectedUrlForEncoding = "/context" + expectedUrlForEncoding;
given(request.getContextPath()).willReturn("/context");
}
given(request.getAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE)).willReturn(new FlashMap());
FlashMapManager flashMapManager = new SessionFlashMapManager();
given(request.getAttribute(DispatcherServlet.FLASH_MAP_MANAGER_ATTRIBUTE)).willReturn(flashMapManager);
HttpServletResponse response = mock(HttpServletResponse.class, "response");
given(response.encodeRedirectURL(expectedUrlForEncoding)).willReturn(expectedUrlForEncoding);
response.sendRedirect(expectedUrlForEncoding);
rv.render(map, request, response);
if (exposeModelAttributes) {
assertTrue("queryProperties() should have been called.", rv.queryPropertiesCalled);
}
}