[英]Page redirect in tapestry5
I am working in web application using tapestry framework. 我正在使用挂毯框架在Web应用程序中工作。 I have following pages a,b,c,d and Index in my application. 我的应用程序中包含以下页面a,b,c,d和索引。 In Index page, check some condition and redirect to a particular page. 在“索引”页面中,检查某些情况并重定向到特定页面。 My code, 我的代码
if(null != cookieVal) {
if(cookieVal.equalsIgnoreCase("a")) {
return A.class;
} else if(cookieVal.equalsIgnoreCase("b")) {
return B.class;
} else if(cookieVal.equalsIgnoreCase("c")) {
return C.class;
} else if(cookieVal.equalsIgnoreCase("d")) {
return D.class;
}
}
Here conditions are increased if pages are increased. 如果增加页面,则会增加条件。 How can I optimize this condition check and redirect to particular page. 如何优化此条件检查并重定向到特定页面。
Return a link created with PageRenderLinkSource service. 返回使用PageRenderLinkSource服务创建的链接。
@Inject
private PageRenderLinkSource pageRenderLinkSource;
...
if(null != cookieVal) {
return pageRenderLinkSource.createPageRenderLink(cookieValue);
}
...
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/PageRenderLinkSource.html http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/PageRenderLinkSource.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.