在搭建lmbbs的项目过程中,第一步就遇到了一个奇葩的问题,我曾没有考虑过的问题。
<%@ page contentType="text/html" pageEncoding="UTF-8"%><jsp:forward page="/PortalServlet/index"></jsp:forward>
用了web.xml的urlPatterns,和@WebServlet的urlPatterns 以/PortalServlet/index尝试映射都失败了。最后我个人认为:
<jsp:forward page="一个资源路径非URI,因为它不会出现在url上。"></jsp:forward>是无法被url隐射到的。如果你把Servlet放入在其中,它找的应该只是那个.class文件。这个是个冷知识点,我至今没有遇到过。特此总结。
其实url也可以使用另外一种格式
http://domain/appName/mudule_action
最简单的方法,在index.jsp页面写一个JS跳转到你的action。
<script language="JavaScript">
window.location.href = "showpage.action";
</script>
第2种方法
就是配欢迎页面为你要跳的action,
在web.xml里设置
<welcom file list>
<welcome-file>welcome.action</welcome-file>
</welcom file list>