Unreachable code
我的 JSP页面中有段代码如下:
TopicBiz tb=new TopicBizImpl();
List topics=tb.getTopics();
request.setAttribute("topics",topics);
String topicId=request.getParameter("ntid");
if(topicId==null) response.sendRedirect("Index.jsp");
return;
%>
报错信息:
An error occurred at line: 170 in the jsp file: /pages/CIndex.jsp
Unreachable code
167: String topicId=request.getParameter("ntid");
168: if(topicId==null) response.sendRedirect("Index.jsp");
169: return;
170: %>
171:
172:
173:
如果代码都写在里使用return 就不会报错,但是我想使用JSTL 标签,我想知道怎样写可以在执行到response.sendRedirect()方法时代码不会往下继续执行,并且我仍然可以使用JSTL标签?
分享到:
更多
------解决方案--------------------
官方的:http://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fn/tld-summary.html
其他的也可以看看http://www.blogjava.net/SkyWinder/archive/2008/11/07/239289.html