标签:
所用的工具为eclipse for javaEE,tomcat 8.0
1.导入jar包
2.在webContent/WEB-INF下新增或编辑web.xml
web.xml的完整内容为:
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" 4 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 5 version="2.5"> 6 <display-name>hadoopWeb</display-name> 7 8 9 <servlet> 10 <servlet-name>spring</servlet-name> 11 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 12 <init-param> 13 <param-name>contextConfigLocation</param-name> 14 <param-value>classpath:spring-servlet.xml</param-value> 15 </init-param> 16 <load-on-startup>1</load-on-startup> 17 </servlet> 18 <servlet-mapping> 19 <servlet-name>spring</servlet-name> 20 <url-pattern>*.do</url-pattern> 21 </servlet-mapping> 22 23 <welcome-file-list> 24 <welcome-file>index.html</welcome-file> 25 </welcome-file-list> 26 </web-app>
这里只拦截.do后缀的请求,spring-servlet.xml放在classpath(右键build path/configure bulid path/source里可以看到哪几个文件夹,也可以在libraries下新增)下就行
标签:
原文地址:http://www.cnblogs.com/zhuzhixijiang/p/5098074.html