2013-07-20 56 views
0

My Struts 2應用程序當前請求資源(jsp,action)時加載資源。一旦應用程序首次部署到容器中以獲得快速響應時間,我需要什麼資源才能加載。我怎樣才能做到這一點? [注意]我使用Tomcat作爲我的Servlet容器。配置struts 2啓動加載

+0

條目這很難告訴你,沒有代碼沒有人能理解你的問題。你應該編輯你的文章並添加詳細信息。 –

回答

0

爲什麼不嘗試實現過濾器...因爲過濾器一旦加載就會從應用程序開始,它可能會有助於加載資源。

您可以在init方法中添加代碼,因爲它將在容器的開始處啓動。

public class TestFilter implements Filter 
{ 


    public void init(FilterConfig config) throws ServletException 
    { 
     System.out.println("PUBLIC Fileter Started."); 
    } 
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
      throws IOException, ServletException 
    { 
//DO NOTHING 
    } 


} 

,並做加在web.xml

<filter> 
     <filter-name>TestFilter</filter-name> 
     <filter-class>com.filter.TestFilter</filter-class> 


    </filter> 

    <filter-mapping> 
     <filter-name>TestFilter</filter-name> 
     <url-pattern>*.action</url-pattern> 
    </filter-mapping>