sitemesh2在tomcat和weblogic中同时使用的配置问题

(一)拦截*.do,装饰器中匹配do

tomcat 可行

weblogic 不可行

web.xml

~~~

<filter>

<filter-name>sitemesh</filter-name>

<filter-class>

com.opensymphony.module.sitemesh.filter.PageFilter

</filter-class>

</filter>

<filter-mapping>

<filter-name>sitemesh</filter-name>

<url-pattern>*.do</url-pattern>

</filter-mapping>

~~~

decorators.xml

~~~

<decorators defaultdir="/pages/_decorators">

<excludes>

</excludes>

<decorator name="index" page="indexde.jsp">

<pattern>/index.do*</pattern>

</decorator>

</decorators>

~~~

(二)拦截forward *.jsp,装饰器中匹配jsp

tomcat 可行

weblogic 可行

web.xml

~~~

<filter>

<filter-name>sitemesh</filter-name>

<filter-class>

com.opensymphony.module.sitemesh.filter.PageFilter

</filter-class>

</filter>

<filter-mapping>

<filter-name>sitemesh</filter-name>

<url-pattern>*.jsp</url-pattern>

<dispatcher>FORWARD</dispatcher>

</filter-mapping>

~~~

decorators.xml

~~~

<decorators defaultdir="/pages/_decorators">

<excludes>

</excludes>

<decorator name="index" page="indexde.jsp">

<pattern>/pages/index*</pattern>

</decorator>

</decorators>

~~~

(三)拦截*.do,装饰器中同时匹配do和jsp

tomcat 可行

weblogic 可行

原因:

摘自 http://markmail.org/message/gmurb6e5lnnivnw2#query:+page:1+mid:2z2pgcifcyi7ukag+state:result

A request comes in to a servlet, that servlet forwards to

a JSP page using RequestDispatcher.forward(). Now, in Tomcat, a call to

request.getServletPath() before and after the call to chain.doFilter() returns

the exact same thing, regardless of whether the target servlet executes a

forward. But in WebLogic, the call to getServletPath() after chain.doFilter()

returns the forwarded path, not the original path. So the path matching that

works in Tomcat doesn't work in WL, and vice-versa.

翻译:

一个请求进入servlet,servlet又使用RequestDispatcher.forward()了一个jsp页面。

在tomcat中,chain.doFilter() 前后使用request.getServletPath() 获得的信息是一致的。

在weblogic中,chain.doFilter() 后使用request.getServletPath() 获得的是forward后的地址。

web.xml

~~~

<filter>

<filter-name>sitemesh</filter-name>

<filter-class>

com.opensymphony.module.sitemesh.filter.PageFilter

</filter-class>

</filter>

<filter-mapping>

<filter-name>sitemesh</filter-name>

<url-pattern>*.do</url-pattern>

</filter-mapping>

~~~

decorators.xml

~~~

<decorators defaultdir="/pages/_decorators">

<excludes>

</excludes>

<decorator name="index" page="indexde.jsp">

<pattern>/pages/index*</pattern>

<pattern>/index.do*</pattern>

</decorator>

</decorators>

~~~

转载于:https://www.cnblogs.com/afarmer/p/3818104.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值