当前位置: 首页>>代码示例>>Java>>正文


Java FrameworkServlet类代码示例

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


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

示例1: getHandlerExecution

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
protected HandlerExecutionChain getHandlerExecution(HttpServletRequest request) throws Exception {

		WebApplicationContext appContext = WebApplicationContextUtils
				.getRequiredWebApplicationContext(request.getServletContext());
		HandlerMapping bean = appContext.getBean(RequestMappingHandlerMapping.class);
		HandlerExecutionChain handler = bean.getHandler(request);

		if (handler == null) {
			ServletContext servletContext = request.getServletContext();
			Enumeration<?> attrNameEnum = servletContext.getAttributeNames();
			while (attrNameEnum.hasMoreElements()) {
				String attrName = (String) attrNameEnum.nextElement();
				if (attrName.startsWith(FrameworkServlet.SERVLET_CONTEXT_PREFIX)) {
					appContext = (WebApplicationContext) servletContext.getAttribute(attrName);
					bean = appContext.getBean(RequestMappingHandlerMapping.class);
					handler = bean.getHandler(request);
					if (handler != null) {
						break;
					}
				}
			}
		}

		return handler;
	}
 
开发者ID:KayuraTeam,项目名称:kayura-uasp,代码行数:26,代码来源:PrivilegeAuthenticationFilter.java

示例2: testRequest

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
@Test
public void testRequest() throws Exception {
    MockServletConfig config = new MockServletConfig();
    MockHttpServletRequest req = new MockHttpServletRequest();
    MockHttpServletResponse res = new MockHttpServletResponse();

    config.addInitParameter("contextConfigLocation", "classpath:spring-web-test.xml");
    req.setMethod("GET");
    req.setRequestURI("/");
    req.setRemoteAddr("1.2.3.4");
    
    DispatcherServlet servlet = new DispatcherServlet();
    servlet.init(config);
    
    servlet.service(req, res);
    
    Method method = FrameworkServlet.class.getDeclaredMethod("doGet", HttpServletRequest.class, HttpServletResponse.class);
    
    PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
    verifier.printCache();
    
    verifier.verifyTrace(Expectations.event(SPRING_MVC, method));
    verifier.verifyTraceCount(0);
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:25,代码来源:SpringWebMvc_5_x_IT.java

示例3: getBeanFactory

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
/**
 * Gets the {@link BeanFactory} from the given {@link JspContext}. The default
 * implementation automagically finds a {@link BeanFactory} that was previously set by
 * a {@link FrameworkServlet}. The result is cached.
 *
 * @param jspContext
 *            {@link JspContext} to be used
 * @return {@link BeanFactory} found
 */
@SuppressWarnings("unchecked")
protected BeanFactory getBeanFactory(JspContext jspContext) {
    Object bfCache = jspContext.getAttribute(TAGPROXY_BEANFACTORY_CACHE, PageContext.APPLICATION_SCOPE);
    if (bfCache != null && bfCache instanceof BeanFactory) {
        return (BeanFactory) bfCache;
    }

    Enumeration<String> en = jspContext.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE);
    while (en.hasMoreElements()) {
        String attribute = en.nextElement();
        if (attribute.startsWith(FrameworkServlet.SERVLET_CONTEXT_PREFIX)) {
            Object bf = jspContext.getAttribute(attribute, PageContext.APPLICATION_SCOPE);
            if (bf != null && bf instanceof BeanFactory) {
                BeanFactory bfBean = (BeanFactory) bf;
                jspContext.setAttribute(TAGPROXY_BEANFACTORY_CACHE, bfBean, PageContext.APPLICATION_SCOPE);
                return bfBean;
            }
        }
    }

    throw new IllegalStateException("Could not find a BeanFactory. Use a FrameworkServlet or @BeanFactoryReference.");
}
 
开发者ID:shred,项目名称:commons-taglib,代码行数:32,代码来源:AbstractTagProxy.java

示例4: registerDispatcherServlet

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
/**
 * Register a {@link DispatcherServlet} against the given servlet context.
 * <p>This method will create a {@code DispatcherServlet} with the name returned by
 * {@link #getServletName()}, initializing it with the application context returned
 * from {@link #createServletApplicationContext()}, and mapping it to the patterns
 * returned from {@link #getServletMappings()}.
 * <p>Further customization can be achieved by overriding {@link
 * #customizeRegistration(ServletRegistration.Dynamic)} or
 * {@link #createDispatcherServlet(WebApplicationContext)}.
 * @param servletContext the context to register the servlet against
 */
protected void registerDispatcherServlet(ServletContext servletContext) {
	String servletName = getServletName();
	Assert.hasLength(servletName, "getServletName() must not return empty or null");

	WebApplicationContext servletAppContext = createServletApplicationContext();
	Assert.notNull(servletAppContext,
			"createServletApplicationContext() did not return an application " +
			"context for servlet [" + servletName + "]");

	FrameworkServlet dispatcherServlet = createDispatcherServlet(servletAppContext);
	dispatcherServlet.setContextInitializers(getServletApplicationContextInitializers());

	ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, dispatcherServlet);
	Assert.notNull(registration,
			"Failed to register servlet with name '" + servletName + "'." +
			"Check if there is another servlet registered under the same name.");

	registration.setLoadOnStartup(1);
	registration.addMapping(getServletMappings());
	registration.setAsyncSupported(isAsyncSupported());

	Filter[] filters = getServletFilters();
	if (!ObjectUtils.isEmpty(filters)) {
		for (Filter filter : filters) {
			registerServletFilter(servletContext, filter);
		}
	}

	customizeRegistration(registration);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:42,代码来源:AbstractDispatcherServletInitializer.java

示例5: init

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    String servletName = config.getServletName();

    urlPattern = config.getInitParameter("uri-pattern");

    if (StringUtils.isEmpty(urlPattern)) {
        throw new ServletException("servlet=" + servletName + "  init-param=uri-prefix cannot be null");
    }

    urlPattern = urlPattern.trim();
    springServletName = config.getInitParameter("spring-servlet-name");
    /*
     * if(urlPattern.endsWith("*")){ urlPattern = urlPattern.substring(0,urlPattern.length()-1); }
     * if(urlPattern.endsWith("/")){ urlPattern = urlPattern.substring(0,urlPattern.length()-1); }
     */

    servicePattern = Pattern.compile(urlPattern);
    ApplicationContext context = null;
    if(springServletName != null){
        String name = FrameworkServlet.SERVLET_CONTEXT_PREFIX+springServletName;
        WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext(), name);
        if(wac != null){
            context = wac;
        }
    }else{
        context = (ApplicationContext) config.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    }
    
    serviceManager = context.getBean(ServiceManager.class);
    try {
        venusExceptionFactory = context.getBean(VenusExceptionFactory.class);
    } catch (BeansException e) {

    }
}
 
开发者ID:blusechen,项目名称:venus,代码行数:37,代码来源:VenusHttpServlet.java

示例6: dispatcherServlet

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
@Bean
public FrameworkServlet dispatcherServlet() {
	return new FrameworkServlet() {
		@Override
		protected void doService(HttpServletRequest request,
				HttpServletResponse response) throws Exception {
		}
	};
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:EmbeddedServletContainerAutoConfigurationTests.java

示例7: init

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
@Before
public void init() throws Exception {
    tester = new ServletTester();
    XmlWebApplicationContext wac;
    tester.setAttribute(Servlet.springCtxAttrName, wac = (XmlWebApplicationContext) FrameworkServlet.DEFAULT_CONTEXT_CLASS.newInstance());
    wac.setConfigLocation("classpath:/com/griddynamics/banshun/controllers-test/parent-context.xml");
    wac.refresh();
    tester.addServlet(Servlet.class, "*.html");
    tester.start();
}
 
开发者ID:jirutka,项目名称:spring-modular,代码行数:11,代码来源:NestedControllerTest.java

示例8: init

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
@Before
public void init() throws Exception {
    tester = new ServletTester();
    XmlWebApplicationContext wac;
    tester.setAttribute(Servlet.springCtxAttrName, wac = (XmlWebApplicationContext) FrameworkServlet.DEFAULT_CONTEXT_CLASS.newInstance());
    wac.setConfigLocation("classpath:/com/griddynamics/banshun/scan-test/parent-context.xml");
    wac.refresh();
    tester.addServlet(Servlet.class, "*.html");
    tester.start();
}
 
开发者ID:jirutka,项目名称:spring-modular,代码行数:11,代码来源:ScanningTest.java

示例9: createDispatcherServlet

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
@Override
protected FrameworkServlet createDispatcherServlet(final WebApplicationContext servletAppContext) {
    final DispatcherServlet dispatcherServlet = new DispatcherServlet(servletAppContext);
    dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);
    return dispatcherServlet;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:7,代码来源:MvcWebApplicationInitializer.java

示例10: createDispatcherServlet

import org.springframework.web.servlet.FrameworkServlet; //导入依赖的package包/类
/**
 * Create a {@link DispatcherServlet} (or other kind of {@link FrameworkServlet}-derived
 * dispatcher) with the specified {@link WebApplicationContext}.
 * <p>Note: This allows for any {@link FrameworkServlet} subclass as of 4.2.3.
 * Previously, it insisted on returning a {@link DispatcherServlet} or subclass thereof.
 */
protected FrameworkServlet createDispatcherServlet(WebApplicationContext servletAppContext) {
	return new DispatcherServlet(servletAppContext);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:AbstractDispatcherServletInitializer.java


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