81,092
社区成员
发帖
与我相关
我的任务
分享
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>indexfilter</filter-name>
<filter-class>com.prodinfo.filter.IndexFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>indexfilter</filter-name>
<url-pattern>/index.jsp</url-pattern>
</filter-mapping>
......
public class IndexFilter implements Filter {
......
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest re = (HttpServletRequest) request;
HttpSession session = re.getSession();
//redirect to action
request.getRequestDispatcher("loadindex.action?id=xxx").forward(
request, response);
System.out.println("i am filter");
}
......
}
<interceptors>
<interceptor name="LoadHeaderFooter"
class="loadHeaderFooter">
</interceptor>
<interceptor-stack name="InterceptorStack">
<interceptor-ref name="defaultStack" />
<interceptor-ref name="LoadHeaderFooter" />
</interceptor-stack>
</interceptors>
<action name="loadindex" class="companyInfoAction"
method="loadCompanyInfo">
<result name="success">/index.jsp</result>
<interceptor-ref name="LoadHeaderFooter"></interceptor-ref>
</action>
......
public String intercept(ActionInvocation invocation) throws Exception {
//System.out.println("Before Action");
//get header & footer infomation
List result = ci.getHeaderFooter("xxx");
......
System.out.println("i am interceptor");
final String res = invocation.invoke();
//System.out.println("After Action");
return res;
}
......