spring4零配置--添加servlet_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > spring4零配置--添加servlet

spring4零配置--添加servlet

 2015/2/28 0:51:21  zhangchengtest  程序员俱乐部  我要评论(0)
  • 摘要:1.实现AbstractAnnotationConfigDispatcherServletInitializer即可取代web.xml/***Baseclassfor{@linkorg.springframework.web.WebApplicationInitializer}*implementationsthatregistera*{@linkorg.springframework.web.servlet.DispatcherServletDispatcherServlet
  • 标签:
1.实现AbstractAnnotationConfigDispatcherServletInitializer即可取代web.xml
class="java">
/**
 * Base class for {@link org.springframework.web.WebApplicationInitializer}
 * implementations that register a
 * {@link org.springframework.web.servlet.DispatcherServlet DispatcherServlet}
 * configured with annotated classes, e.g. Spring's
 * {@link org.springframework.context.annotation.Configuration @Configuration} classes.
 *
 * <p>Concrete implementations are required to implement {@link #getRootConfigClasses()}
 * and {@link #getServletConfigClasses()} as well as {@link #getServletMappings()}.
 * Further template and customization methods are provided by
 * {@link AbstractDispatcherServletInitializer}.
 *
 * @author Arjen Poutsma
 * @author Chris Beams
 * @since 3.2
 */
public abstract class AbstractAnnotationConfigDispatcherServletInitializer


2.
/**
	 * 添加Servlet
	 */
	protected void registerDispatcherServlet(ServletContext servletContext) {
		super.registerDispatcherServlet(servletContext);
		try {
			 ServletRegistration.Dynamic dynamic= servletContext.addServlet("frontPay", (HttpServlet)Class.forName("com.unionpay.upop.sdk.common.FrontPayServLet").newInstance());
			 dynamic.addMapping("/frontPay");
		} catch (Exception e)
		{
			e.printStackTrace();
		}
	}

  • 相关文章
发表评论
用户名: 匿名