- 我有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 url-pattern的> filter-mapping的>' –
Raju
编辑你的问题,从web.xml中把相关的代码/应用/等 – yeppe