在 Jetty 中禁用 JSP servlet
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加
*.jsp
将此扩展映射到您的调度程序 servlet。Add a
<servlet-mapping>*.jsp</servlet-mapping>
to map this extension to your dispatcher servlet.