當前位置: 首頁>>代碼示例>>Java>>正文


Java SessionFlashMapManager類代碼示例

本文整理匯總了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);
	}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:26,代碼來源:StandaloneMockMvcBuilder.java

示例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());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:8,代碼來源:RedirectViewUriTemplateTests.java

示例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"));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:14,代碼來源:RedirectViewTests.java

示例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);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:30,代碼來源:StandaloneMockMvcBuilder.java

示例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"));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:10,代碼來源:MockHttpServletRequestBuilderTests.java

示例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;
}
 
開發者ID:motech,項目名稱:motech,代碼行數:15,代碼來源:FlashMapInterceptor.java

示例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"));
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:10,代碼來源:MockHttpServletRequestBuilderTests.java

示例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;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:7,代碼來源:RedirectViewTests.java

示例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);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:48,代碼來源:RedirectViewTests.java


注:本文中的org.springframework.web.servlet.support.SessionFlashMapManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。