首页 > Web开发 > 详细

different between<A Href> and <jsp: forward>

时间:2014-03-18 17:01:42      阅读:453      评论:0      收藏:0      [点我收藏+]

i want to access Servelt by hyperlink in a jsp web site connection.jsp

<%@ page contentType="text/html;charset=GB2312"

 %>
<HTML>
<BODY bgcolor=cyan><Font size=1>
<A Href="/myjsp/Hello"

 >Accessing servlet<A>
</BODY>
</HTML

i put the bean in the dir(/myjsp/WEB-INF/classes/hello(package)/Hello) and modify the file web.xml like this:

><servlet>
        <servlet-name>Hello</servlet-name>
        <servlet-class>hello.Hello</servlet-class>
    </servlet>
    <servlet-mapping>
  	<servlet-name>Hello</servlet-name>
  	<url-pattern>/Hello</url-pattern>
    </servlet-mapping>

it works! but if i use <jsp:forward>

<html>
	<body bgcolor="green"

>
	
	<jsp:forward page="/myjsp/Hello"

 />
	<body>
</html>

it causes an Exception The requested resource (/myjsp/myjsp/SimpleServlet) is not available.
but if you rewrite the path like this <jasp:forward page="/Hello"/> it will be ok.   why? in my opinion, if you use <A Href=..> the default path is http://localhost:8080 so you need the rest path is /myjsp/Hello. but if you use <jsp:forward> the default path is http://localhost:8080/myjsp/,so you just need write the rest part"/Hello". i don‘t know my explaination is right or not. but i think this is a try.

different between<A Href> and <jsp: forward>,布布扣,bubuko.com

different between<A Href> and <jsp: forward>

原文:http://www.cnblogs.com/ejllen/p/3607993.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!