- 我有Apache和配置如下:
RewriteEngine On ProxyPass/http://demo1.example.com:8080/myApp ProxyPassReverse/....(same url as above)
以下是web.xml中:Struts2的靜態內容給404
<filter> <filter-name>struts2</filter-name> <filter- class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter> <filter-name>UrlFilter</filter-name> <filter-class>com.rts.utils.UrlFilter</filter-class> </filter> <filter-mapping> <filter-name>UrlFilter</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
我已經定製過濾器,從URL中讀取subdoman並在請求中設置:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) request; if(httpReq.getServerName() != null && httpReq.getServerName().indexOf(".") != -1) { request.setAttribute("subdomain",...); chain.doFilter(request, response); } }
我使用的是struts 2.3.8,Tomcat 6 & JDK 1.6。我在webapps/myApp下部署了我的應用程序。
當我登錄到應用程序中,我可以看到404下面的網址和我的網頁不能正常加載:
http://example.com/myApp/struts/js/base/jquery-1.8.3.js
如果我嘗試了上面的URL(直接在瀏覽器)不給「對myApp」,像下面我收到劇本
http://example.com/struts/js/base/jquery-1.8.3.js
這意味着struts2中不生成正確的contextPath靜態內容?
你有什麼其他的過濾器?你能複製你的代碼的相關部分嗎? – yeppe
@yeppe感謝您的回覆..是的,我有另一個自定義的過濾器來讀取子域名。下面是該代碼:' \t UrlFilter \t <濾波器級> com.rts.utils.UrlFilter <濾波器映射> \t UrlFilter \t * .action ' –
Raju
編輯你的問題,從web.xml中把相關的代碼/應用/等 – yeppe