开发者

Spring framework Servlet hiding regular Java HttpServlet

I am developing a Java application that is to have two web interfaces: a servlet handling some web service logic (/WSProxy) and a web admin interface using the Spring framework (/Admin or *.html). My problem is that the Spring framework dispatcher is hiding the other Servlet; I can view the logs and see that my Admin Servlet is loaded in the server log but every time I try to navigate to it in my browser, it appears as though the Sping Servlet is trying to handle the request! Thanks.

My web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>RicochetAdmin</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>RicochetProxy</servlet-name>
        <servlet-class>WSProxy.Servlets.RicochetProxy</servlet-class>
        <init-param>
            <param-name>ricochet.xml.path</param-name>
            <param-value>C:\Users\cdix\Documents\NetBeansProjects\Ricochet\web\WEB-INF\conf\ricochet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>RicochetProxy</servlet-name>
        <url-pattern>/RicochetProxy/*</url-pattern>
        <url-pattern>/RicochetProxy</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>RicochetAdmin</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    &l开发者_高级运维t;welcome-file-list>
        <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
</web-app>


Assuming Ricochet is your app (war) name, you'd need to change the second mapping from .html to /RicochetAdmin/.html. The way you have it now the Spring dispatcher is being called for every request ending with .html.


Change ordering of your servlet mappings in web.xml so that Spring's dispatcher is loaded after your other servlet.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜