简体   繁体   English

Spring框架Servlet隐藏常规Java HttpServlet

[英]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). 我正在开发一个具有两个Web界面的Java应用程序:一个处理某些Web服务逻辑的Servlet(/ WSProxy)和一个使用Spring框架(/ Admin或* .html)的Web管理员界面。 My problem is that the Spring framework dispatcher is hiding the other Servlet; 我的问题是Spring框架调度程序隐藏了另一个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! 我可以查看日志,并看到我的Admin Servlet已加载到服务器日志中,但是每次我尝试在浏览器中导航到它时,似乎Sping Servlet都在尝试处理该请求! Thanks. 谢谢。

My web.xml file: 我的web.xml文件:

<?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>
    <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. 假设Ricochet是您的应用程序(战争)名称,则需要将第二个映射从.html更改为/ RicochetAdmin / .html。 The way you have it now the Spring dispatcher is being called for every request ending with .html. 您现在拥有的方式将为每个以.html结尾的请求调用Spring调度程序。

更改web.xml servlet映射的顺序,以便在其他servlet之后加载Spring的调度程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 扩展Spring Framework(Java)Servlet - Extending The Spring Framework (Java) Servlet Java缺少javax.servlet.httpservlet - Java missing javax.servlet.httpservlet 在 Java 构建路径上找不到超类“javax.servlet.http.HttpServlet” - The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path 引起:java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet - Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet 如何在Spring Framework Java Web应用程序中添加Servlet? - How do I add a servlet to spring framework java web application? 使用Servlet 2.5测试Spring Framework 4 - Testing Spring Framework 4 with Servlet 2.5 隐藏Java MVC Web应用程序中的视图servlet? - Hiding a view servlet in a Java MVC web application? 字节预算抛出java.lang.ClassNotFoundException:javax.servlet.http.HttpServlet - byte-buddy throws java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet 从intellij启动springboot项目时出现“引起:java.lang.NoClassDefFoundError:javax / servlet / http / HttpServlet” - getting a “Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet” when starting springboot project from intellij iText 5: Create a single PDF "ByteArrayOutputStream()" from two streams in a Java "HttpServlet" servlet to display in browser window - iText 5: Create a single PDF "ByteArrayOutputStream()" from two streams in a Java "HttpServlet" servlet to display in browser window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM