【问题标题】:Jetty automatically loads JSP support, how can that be turned off?Jetty 自动加载 JSP 支持,怎么关闭呢?
【发布时间】:2010-11-09 07:57:52
【问题描述】:

在我的日志中,当 Jetty 启动时,我看到以下内容:

 +-WebAppContext@560c3014@560c3014/,file:/C:/MyProjects/ProxyServer/PrepayProxyWebsiteJetty/webapps/root/,webapps/root started
    +-{org.apache.catalina.jsp_classpath=C:\MyProjects\ProxyServer\PrepayProxyWebsiteJetty\webapps\root\WEB-INF\classes, javax.servlet.context.tempdir=C:\Users\davidparks21\AppData\Local\Temp\jetty-0.0.0.0-80-root-_-any-}
    +-{org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher=WebApplicationContext for namespace 'dispatcher-servlet': startup date [Tue Nov 09 14:38:47 ICT 2010]; parent: Root WebApplicationContext, org.springframework.web.context.support.ServletContextScope=org.springframework.web.context.support.ServletContextScope@3ab6f7f5, org.springframework.web.context.WebApplicationContext.ROOT=Root WebApplicationContext: startup date [Tue Nov 09 14:38:46 ICT 2010]; root of context hierarchy}
    +-SessionHandler@6f7918f0 started
       +-ConstraintSecurityHandler@47f08ed8 started
          +-[]
          +-/={TRACE={RoleInfo,F,C[]}}
          +-ServletHandler@77546dbc started
             +-[/*]/[]==0=>springSecurityFilterChain{}
             +-[/]=>default{resourceCache=resourceCache, maxCacheSize=256000000, dirAllowed=true, gzip=true, maxCachedFileSize=10000000, redirectWelcome=false, acceptRanges=true, welcomeServlets=false, aliases=false, useFileMappedBuffer=true, maxCachedFiles=2048}
             +-[*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX, *.XSP]=>jsp{logVerbosityLevel=DEBUG, fork=false, com.sun.appserv.jsp.classpath=<list_removed>, xpoweredBy=false, scratchdir=C:\Users\davidparks21\AppData\Local\Temp\jetty-0.0.0.0-80-root-_-any-\jsp}
             +-[/]=>dispatcher{}

在我的 webapps web.xml 中我定义了 springSecurityFilterChain() 和 dispatcher(),但是我没有定义 default 和 jsp。

JSP 支持似乎默认开启,这不应该,我使用速度。有没有办法禁用它?

我还看到有一个默认设置 dirAllowed=true,这让我很紧张,不应该存在吗?

我的 web.xml:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                             http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

    <!-- ~~~~~~~~~~~~~~~ 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 ~~~~~~~~~~~~~~~ -->
    <!-- All web requests go through security validation -->
    <filter>
      <filter-name>springSecurityFilterChain</filter-name>
      <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- ~~~~~~~~~~~~~~~ BEAN SCOPES FOR WEB ~~~~~~~~~~~~~~~ -->
    <!-- Adds support for scoping beans as: 'request', 'session', and 'global session' -->
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

</web-app>

【问题讨论】:

    标签: java web-applications spring-mvc jetty


    【解决方案1】:

    在 Jetty 7.1.2 中,如果 lib/jsp 中的类在 Jetty 的类路径中,则 JSP 支持将打开,否则将关闭。 start.jar 的 OPTIONS=jsp 参数只是控制它们在类路径中的存在。

    另一个禁用 JSP 支持的选项来自mailing list。本质上,每个部署的 Web 应用程序的默认描述符都包含一个 JSP/Servlet 映射。如果不需要 JSP,则通过将 setDefaultsDescriptor 设置为 null 为给定上下文禁用它。例如:

    WebAppContext wac = new WebAppContext();
    wac.setDefaultsDescriptor( null ); 
    

    详情请参阅WebAppContext documentation

    【讨论】:

    • 这是 Jetty 7.2.0。我只是注意到看起来很奇怪的日志文件似乎暗示 JSP 支持已启用,但我实际上并没有尝试让它工作。我在任何地方都没有任何 JSP 或 jsp 文件夹。
    • 我确定在您下载的码头分发目录中,您有一个 lib/jsp 目录,除非您手动删除它。
    猜你喜欢
    • 2015-11-21
    • 2023-03-15
    • 2016-08-07
    • 1970-01-01
    • 2017-08-22
    • 2012-12-04
    • 1970-01-01
    • 2014-08-18
    • 2019-04-02
    相关资源
    最近更新 更多