奇葩的urlPatterns的映射问题

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

最简单的方法,在index.jsp页面写一个JS跳转到你的action<script language="JavaScript">
window.location.href = "showpage.action";
</script>

2种方法
 就是配欢迎页面为你要跳的actionweb.xml里设置
<welcom file list>
<welcome-file>welcome.action</welcome-file>
</welcom file list>

猜你喜欢

转载自blog.csdn.net/wdw18668109050/article/details/79001778
今日推荐