• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParameterizableViewController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.web.servlet.mvc.ParameterizableViewController的典型用法代码示例。如果您正苦于以下问题:Java ParameterizableViewController类的具体用法?Java ParameterizableViewController怎么用?Java ParameterizableViewController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParameterizableViewController类属于org.springframework.web.servlet.mvc包,在下文中一共展示了ParameterizableViewController类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: rootController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Bean
protected Controller rootController() {
    return new ParameterizableViewController() {
        @Override
        protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) 
                throws Exception {
            final String queryString = request.getQueryString();
            final String url = request.getContextPath() + "/login" + (queryString != null ? '?' + queryString : StringUtils.EMPTY);
            return new ModelAndView(new RedirectView(response.encodeURL(url)));
        }
    };
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:13,代码来源:CasApplicationContextConfiguration.java


示例2: testViewControllersDefaultConfig

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Test
public void testViewControllersDefaultConfig() {
	loadBeanDefinitions("mvc-config-view-controllers-minimal.xml", 7);

	SimpleUrlHandlerMapping hm = this.appContext.getBean(SimpleUrlHandlerMapping.class);
	assertNotNull(hm);
	ParameterizableViewController viewController = (ParameterizableViewController) hm.getUrlMap().get("/path");
	assertNotNull(viewController);
	assertEquals("home", viewController.getViewName());

	ParameterizableViewController redirectViewController = (ParameterizableViewController) hm.getUrlMap().get("/old");
	assertNotNull(redirectViewController);
	assertThat(redirectViewController.getView(), Matchers.instanceOf(RedirectView.class));

	ParameterizableViewController statusViewController = (ParameterizableViewController) hm.getUrlMap().get("/bad");
	assertNotNull(statusViewController);
	assertEquals(404, statusViewController.getStatusCode().value());

	BeanNameUrlHandlerMapping beanNameMapping = this.appContext.getBean(BeanNameUrlHandlerMapping.class);
	assertNotNull(beanNameMapping);
	assertEquals(2, beanNameMapping.getOrder());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:MvcNamespaceTests.java


示例3: rootController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Bean
protected Controller rootController() {
    return new ParameterizableViewController() {
        @Override
        protected ModelAndView handleRequestInternal(final HttpServletRequest request,
                                                     final HttpServletResponse response)
                throws Exception {
            final String queryString = request.getQueryString();
            final String url = request.getContextPath() + "/login"
                    + (queryString != null ? '?' + queryString : StringUtils.EMPTY);
            return new ModelAndView(new RedirectView(response.encodeURL(url)));
        }

    };
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:CasWebAppConfiguration.java


示例4: rootController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Bean
protected Controller rootController() {
    return new ParameterizableViewController() {
        protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
            String queryString = request.getQueryString();
            String url = request.getContextPath() + "/login" + (queryString != null ? '?' + queryString : "");
            return new ModelAndView(new RedirectView(response.encodeURL(url)));
        }
    };
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:11,代码来源:CasWebAppConfiguration.java


示例5: addViewController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Test
public void addViewController() {
	this.registry.addViewController("/path").setViewName("viewName");
	ParameterizableViewController controller = getController("/path");

	assertEquals("viewName", controller.getViewName());
	assertNull(controller.getStatusCode());
	assertFalse(controller.isStatusOnly());
	assertNotNull(controller.getApplicationContext());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:ViewControllerRegistryTests.java


示例6: addViewControllerWithDefaultViewName

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Test
public void addViewControllerWithDefaultViewName() {
	this.registry.addViewController("/path");
	ParameterizableViewController controller = getController("/path");

	assertNull(controller.getViewName());
	assertNull(controller.getStatusCode());
	assertFalse(controller.isStatusOnly());
	assertNotNull(controller.getApplicationContext());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:ViewControllerRegistryTests.java


示例7: addStatusController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Test
public void addStatusController() {
	this.registry.addStatusController("/path", HttpStatus.NOT_FOUND);
	ParameterizableViewController controller = getController("/path");

	assertNull(controller.getViewName());
	assertEquals(HttpStatus.NOT_FOUND, controller.getStatusCode());
	assertTrue(controller.isStatusOnly());
	assertNotNull(controller.getApplicationContext());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:ViewControllerRegistryTests.java


示例8: getRedirectView

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
private RedirectView getRedirectView(String path) {
	ParameterizableViewController controller = getController(path);
	assertNull(controller.getViewName());
	assertNotNull(controller.getView());
	assertEquals(RedirectView.class, controller.getView().getClass());
	return (RedirectView) controller.getView();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:ViewControllerRegistryTests.java


示例9: WelcomePageHandlerMapping

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
WelcomePageHandlerMapping(Collection<String> paths) {
    ParameterizableViewController controller = new ParameterizableViewController();
    controller.setViewName("forward:" + target);
    paths.forEach(path -> registerHandler(path, controller));
    //we handle only non handled resources, but resource handler (which has LOWEST_PRECEDENCE - 1) handle all
    setOrder(LOWEST_PRECEDENCE - 10);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:8,代码来源:WelcomePageHandlerMapping.java


示例10: parse

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
public BeanDefinition parse(Element element, ParserContext parserContext) {
	Object source = parserContext.extractSource(element);

	// Register SimpleUrlHandlerMapping for view controllers
	BeanDefinition handlerMappingDef = registerHandlerMapping(parserContext, source);

	// Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
	MvcNamespaceUtils.registerDefaultComponents(parserContext, source);

	// Create view controller bean definition
	RootBeanDefinition viewControllerDef = new RootBeanDefinition(ParameterizableViewController.class);
	viewControllerDef.setSource(source);
	if (element.hasAttribute("view-name")) {
		viewControllerDef.getPropertyValues().add("viewName", element.getAttribute("view-name"));
	}
	Map<String, BeanDefinition> urlMap;
	if (handlerMappingDef.getPropertyValues().contains("urlMap")) {
		urlMap = (Map<String, BeanDefinition>) handlerMappingDef.getPropertyValues().getPropertyValue("urlMap").getValue();
	}
	else {
		urlMap = new ManagedMap<String, BeanDefinition>();
		handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
	}
	urlMap.put(element.getAttribute("path"), viewControllerDef);

	return null;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:28,代码来源:ViewControllerBeanDefinitionParser.java


示例11: addViewController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Test
public void addViewController() {
	registry.addViewController("/path");
	Map<String, ?> urlMap = getHandlerMapping().getUrlMap();
	ParameterizableViewController controller = (ParameterizableViewController) urlMap.get("/path");
	assertNotNull(controller);
	assertNull(controller.getViewName());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:ViewControllerRegistryTests.java


示例12: addViewControllerWithViewName

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Test
public void addViewControllerWithViewName() {
	registry.addViewController("/path").setViewName("viewName");
	Map<String, ?> urlMap = getHandlerMapping().getUrlMap();
	ParameterizableViewController controller = (ParameterizableViewController) urlMap.get("/path");
	assertNotNull(controller);
	assertEquals("viewName", controller.getViewName());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:ViewControllerRegistryTests.java


示例13: getViewController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
protected ParameterizableViewController getViewController() {
	return this.controller;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:ViewControllerRegistration.java


示例14: parse

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public BeanDefinition parse(Element element, ParserContext parserContext) {
	Object source = parserContext.extractSource(element);

	// Register SimpleUrlHandlerMapping for view controllers
	BeanDefinition hm = registerHandlerMapping(parserContext, source);

	// Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
	MvcNamespaceUtils.registerDefaultComponents(parserContext, source);

	// Create view controller bean definition
	RootBeanDefinition controller = new RootBeanDefinition(ParameterizableViewController.class);
	controller.setSource(source);

	HttpStatus statusCode = null;
	if (element.hasAttribute("status-code")) {
		int statusValue = Integer.valueOf(element.getAttribute("status-code"));
		statusCode = HttpStatus.valueOf(statusValue);
	}

	String name = element.getLocalName();
	if (name.equals("view-controller")) {
		if (element.hasAttribute("view-name")) {
			controller.getPropertyValues().add("viewName", element.getAttribute("view-name"));
		}
		if (statusCode != null) {
			controller.getPropertyValues().add("statusCode", statusCode);
		}
	}
	else if (name.equals("redirect-view-controller")) {
		controller.getPropertyValues().add("view", getRedirectView(element, statusCode, source));
	}
	else if (name.equals("status-controller")) {
		controller.getPropertyValues().add("statusCode", statusCode);
		controller.getPropertyValues().add("statusOnly", true);
	}
	else {
		// Should never happen...
		throw new IllegalStateException("Unexpected tag name: " + name);
	}

	Map<String, BeanDefinition> urlMap;
	if (hm.getPropertyValues().contains("urlMap")) {
		urlMap = (Map<String, BeanDefinition>) hm.getPropertyValues().getPropertyValue("urlMap").getValue();
	}
	else {
		urlMap = new ManagedMap<String, BeanDefinition>();
		hm.getPropertyValues().add("urlMap", urlMap);
	}
	urlMap.put(element.getAttribute("path"), controller);

	return null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:55,代码来源:ViewControllerBeanDefinitionParser.java


示例15: setUp

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this.controller = new ParameterizableViewController();
	this.request = new MockHttpServletRequest("GET", "/");
	this.response = new MockHttpServletResponse();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:ParameterizableViewControllerTests.java


示例16: getController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
private ParameterizableViewController getController(String path) {
	Map<String, ?> urlMap = getHandlerMapping().getUrlMap();
	ParameterizableViewController controller = (ParameterizableViewController) urlMap.get(path);
	assertNotNull(controller);
	return controller;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:ViewControllerRegistryTests.java


示例17: getViewController

import org.springframework.web.servlet.mvc.ParameterizableViewController; //导入依赖的package包/类
/**
 * Returns the view controllers.
 */
protected Object getViewController() {
	ParameterizableViewController controller = new ParameterizableViewController();
	controller.setViewName(viewName);
	return controller;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:9,代码来源:ViewControllerRegistration.java



注:本文中的org.springframework.web.servlet.mvc.ParameterizableViewController类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SyncService类代码示例发布时间:2022-05-22
下一篇:
Java NotesFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap