在 Jetty 中禁用 JSP servlet

发布于 2024-10-25 23:45:48 字数 3390 浏览 1 评论 0原文

我正在使用 Spring 和 Jetty。到目前为止,我还没有使用过 JSP,但我有一个使用它们的第 3 方 servlet。

日志中显示 Jetty 正在尝试加载“jsp”servlet。但我希望所有请求都通过 springs 调度程序 servlet。

我该如何阻止 Jetty 拦截 *.jsp?

web.xml

<web-app xmlns:...

    <!-- ~~~~~~~~~~~~~~~ SPRING DISPATCHER SERVLET ~~~~~~~~~~~~~~~ -->
    <!-- Allows Spring to handle all web requests -->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- ~~~~~~~~~~~~~~~ SPRING SECURITY HOOK ~~~~~~~~~~~~~~~ -->
    <!-- removed for clarity -->

    <!-- ~~~~~~~~~~~~~~~ BEAN SCOPES FOR WEB ~~~~~~~~~~~~~~~ -->
    <!-- removed for clarity -->

</web-app>

非 JSP 请求的 Jetty 日志:

28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - REQUEST /myaccount/transactions on org.eclipse.jetty.server.nio.SelectChannelConnector$3@52d85409
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - Got Session ID 1x85qr20xozki139cfcd6a520o from cookie
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - sessionManager=org.eclipse.jetty.server.session.HashSessionManager@21e3cc77
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - session=org.eclipse.jetty.server.session.HashSessionManager$HashedSession:1x85qr20xozki139cfcd6a520o@1420624050
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - servlet=dispatcher
28903 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - servlet holder=
28903 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - chain=
28903 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - call filter springSecurityFilterChain

JSP 请求的 Jetty 日志:

398317 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - REQUEST /console/login.jsp on org.eclipse.jetty.server.nio.SelectChannelConnector$3@1eaf0e38
398317 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - Got Session ID 1x85qr20xozki139cfcd6a520o from cookie
398317 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - sessionManager=org.eclipse.jetty.server.session.HashSessionManager@21e3cc77
398318 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - session=org.eclipse.jetty.server.session.HashSessionManager$HashedSession:1x85qr20xozki139cfcd6a520o@1420624050
398318 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - servlet=jsp
398319 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - servlet holder=
398319 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - chain=
398319 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - call filter springSecurityFilterChain

I'm using Spring with Jetty. Until now I haven't used JSP's, but I have a 3rd party servlet that uses them.

It appears in the logs that Jetty is trying to load a "jsp" servlet. But I want all requests to go through to springs dispatcher servlet.

What can I do to stop Jetty from intercepting *.jsp?

web.xml

<web-app xmlns:...

    <!-- ~~~~~~~~~~~~~~~ SPRING DISPATCHER SERVLET ~~~~~~~~~~~~~~~ -->
    <!-- Allows Spring to handle all web requests -->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- ~~~~~~~~~~~~~~~ SPRING SECURITY HOOK ~~~~~~~~~~~~~~~ -->
    <!-- removed for clarity -->

    <!-- ~~~~~~~~~~~~~~~ BEAN SCOPES FOR WEB ~~~~~~~~~~~~~~~ -->
    <!-- removed for clarity -->

</web-app>

Jetty logs for a non-JSP request:

28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - REQUEST /myaccount/transactions on org.eclipse.jetty.server.nio.SelectChannelConnector$3@52d85409
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - Got Session ID 1x85qr20xozki139cfcd6a520o from cookie
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - sessionManager=org.eclipse.jetty.server.session.HashSessionManager@21e3cc77
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - session=org.eclipse.jetty.server.session.HashSessionManager$HashedSession:1x85qr20xozki139cfcd6a520o@1420624050
28902 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - servlet=dispatcher
28903 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - servlet holder=
28903 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - chain=
28903 [qtp1620636050-15 - /myaccount/transactions] DEBUG org.eclipse.jetty.util.log  - call filter springSecurityFilterChain

Jetty logs for a JSP request:

398317 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - REQUEST /console/login.jsp on org.eclipse.jetty.server.nio.SelectChannelConnector$3@1eaf0e38
398317 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - Got Session ID 1x85qr20xozki139cfcd6a520o from cookie
398317 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - sessionManager=org.eclipse.jetty.server.session.HashSessionManager@21e3cc77
398318 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - session=org.eclipse.jetty.server.session.HashSessionManager$HashedSession:1x85qr20xozki139cfcd6a520o@1420624050
398318 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - servlet=jsp
398319 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - servlet holder=
398319 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - chain=
398319 [qtp1620636050-14 - /console/login.jsp] DEBUG org.eclipse.jetty.util.log  - call filter springSecurityFilterChain

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

篱下浅笙歌 2024-11-01 23:45:48

添加 *.jsp 将此扩展映射到您的调度程序 servlet。

Add a <servlet-mapping>*.jsp</servlet-mapping> to map this extension to your dispatcher servlet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文