[英]Embedded pages using doFilter in xhtml not working
我在我的項目中應用了過濾器,如下所示:
public class Filter implements javax.servlet.Filter{
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
if (((HttpServletRequest) request).getSession().getAttribute("admin") == null) {
// Not logged in, so redirect request to login page.
((HttpServletResponse) response).sendRedirect("../index.xhtml");
}
}
@Override
public void init(FilterConfig arg0) throws ServletException {
// TODO Auto-generated method stub
}
其在web.xml中的條目如下
<filter>
<filter-name>Filter</filter-name>
<filter-class>com.kc.aop.bean.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>Filter</filter-name>
<url-pattern>/admin/*</url-pattern>
</filter-mapping>
我的管理文件夾中有以下文件:
dashboard.xhtml
introduction.xhtml
news.xhtml
Introduction.xhtml和news.xhtml使用以下方法嵌入dashboard.xhtml中
<iframe id= "iframe" width="1000px" height="300px" src="introduction.xhtml"></iframe>
我在index.xhtml中有一個登錄名,但是當我嘗試登錄時,可以看到我的dashboard.xhtml,但是使用introduction.xhtml的iframe顯示以下錯誤。
XML Parsing Error: no element found
Location: http://localhost:8080/AOP/admin/introduction.xhtml
Line Number 1, Column 1:
任何想法,為什么這樣的行為。 他們的doFilter實現有問題嗎?
您需要調用filterChain.doFilter(request, response);
在您的doFilter
方法實現中。 否則,您的其余過濾器將不會被調用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.