zoukankan      html  css  js  c++  java
  • different between<A Href> and <jsp: forward>

    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.

  • 相关阅读:
    拥有最多糖果的孩子
    求1+2+…+n
    网络-中间代理
    Header中的Referer属性表示
    ios13.4post请求出现网错错误 network err
    10.8&10.10
    9.23&9.27
    9.16&9.19
    校内模拟赛划水报告(9.9,9.11)
    男人八题 划水题解
  • 原文地址:https://www.cnblogs.com/ejllen/p/3607993.html
Copyright © 2011-2022 走看看