我在Google App Engine中遇到了白名单重定向和Servlet问题。 我有一个index.jsp和一个list.jsp,但我无法得到预期的结果。Google App Engine(Java) - 从web.xml重定向到jsp
我有这个在web.xml:
<filter-name>URIParserFilter</filter-name>
<filter-class>com.bbva.icaro2.web.filters.URIParserFilter</filter-class>
</filter>
<servlet>
<servlet-name>EntitiesAdminServlet</servlet-name>
<servlet-class>com.myproject.web.EntitiesAdminServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>ListServlet</servlet-name>
<servlet-class>com.myproject.web.ListServlet</servlet-class>
<jsp-files>/lists/lists.jsp</jsp-files>
</servlet>
<servlet-mapping>
<servlet-name>EntitiesAdminServlet</servlet-name>
<url-pattern>/admin/entities/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ListServlet</servlet-name>
<url-pattern>/lists/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
当我访问http://myproject/lists/mylist 线程去URIParserFilter:
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
String entityKind = null;
String id = null;
String pathInfo = ((HttpServletRequest)req).getPathInfo();
String pathString = (pathInfo == null || pathInfo.equals("/")) ? "" : pathInfo.substring(1);
String[] parts = pathString.split("/");
entityKind = parts[0].trim();
id = (parts.length > 1) ? parts[1].trim() : null;
req.setAttribute(Constants.REQ_ATTR_REQ_ENTITYKIND, entityKind); // entityKind = "mylist"
req.setAttribute(Constants.REQ_ATTR_REQ_ENTITYID, id);
chain.doFilter(req, resp);
}
然后它去的List.jsp whitout通过ListServlet :-( 在http://myproject/admin/entities/hello的情况下,它的工作原理!
这些类是完全一样的...
我做错了什么?
谢谢,我的英语不好对不起......
IThanks的回答,它重定向到我的jsp“lists.jsp”但线程不经过我的servlet:ListServlet – tpdeoro 2012-03-14 12:04:27
那么你想使用RequestDispatcher在servlet代码内部重定向。 – 2012-03-14 12:06:39
但是...它从URIParserFilter.doFilter()直接到“lists.jsp”,我怎么能强制它通过我的servlet重定向它? 我想我在我的web.xml中遇到了错误,但我不知道是什么 – tpdeoro 2012-03-14 12:15:06