日期:2014-05-17  浏览次数:20665 次

web.xml里面有关url-pattern配置的问题

<servlet>
<servlet-name>webappServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/webapp-dispatcher.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webappServlet</servlet-name>
<url-pattern>/web/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>wapappServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/wapapp-dispatcher.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>wapappServlet</servlet-name>
<url-pattern>/wap/*</url-pattern>
</servlet-mapping>




以上 如果使用 /wap/index 或者/web/index则能准确匹配,但是使用*号 或者直接使用/web/之类则全部报404错误。在线等 很急 谢谢

------解决方案--------------------
<servlet>         <servlet-name>webappServlet</servlet-name>         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>         <init-param>             <param-name>contextConfigLocation</param-name>             <param-value>/WEB-INF/conf/webapp-dispatcher.xml</param-value>         </init-param>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>webappServlet</servlet-name>         <url-pattern>/web/*</url-pattern>     </servlet-mapping>       <servlet>         <servlet-name>wapappServlet</servlet-name>         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>         <init-param>             <param-name>contextConfigLocation</param-name>             <param-value>/WEB-INF/conf/wapapp-dispatcher.xml</param-value>         </init-param>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>wapappServlet</servlet-name>         <url-pattern>/wap/*</url-pattern>     </servlet-mapping> 
2个名字一样的servlet?似乎按照你的说法