2010-11-09 15 views
2

在我的日誌,我看到下面的碼頭時開始:Jetty自動加載JSP支持,該如何關閉?

[email protected]@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.ServletContextSc[email protected]3ab6f7f5, org.springframework.web.context.WebApplicationContext.ROOT=Root WebApplicationContext: startup date [Tue Nov 09 14:38:46 ICT 2010]; root of context hierarchy} 
    [email protected] started 
     [email protected] started 
      +-[] 
      +-/={TRACE={RoleInfo,F,C[]}} 
      [email protected] 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{} 

在我的web應用的web.xml我定義springSecurityFilterChain()和調度(),但我沒有定義默認和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> 

回答

1

在碼頭7.1.2,JSP的支持將是如果LIB/JSP類在碼頭的類路徑,並關閉其他。 start.jar的OPTIONS = jsp參數只是控制它們在類路徑中的存在。

另一個禁用JSP支持的選項來自mailing list。本質上,每個部署的Web應用程序的默認描述符都包含一個JSP/Servlet映射。如果JSP不是必需的,那麼通過將setDefaultsDescriptor設置爲null來針對給定上下文禁用它。例如:

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

WebAppContext documentation瞭解詳情。

+0

這是Jetty 7.2.0。我只注意到這個奇怪的日誌文件,似乎暗示着JSP支持,但我實際上沒有試圖使它工作。我沒有任何地方有任何JSP或jsp文件夾。 – 2010-11-18 02:55:58

+0

我確定在你下載的jetty發行版目錄中有一個lib/jsp目錄,除非你手動刪除它。 – bmargulies 2010-11-18 15:30:54

+0

不幸的是,這對Jetty 9.3.0不起作用 – 2015-07-10 13:02:11