form表单的action参数值和web.xml中的<url-pattern>

来源:互联网 发布:linux 倒序查看文件 编辑:程序博客网 时间:2024/06/14 06:17
<form action="checklogin" method="post" name="form" onsubmit="return login()"><table align="center" width="455" height="133" border="1"><tr><td align="center" colspan="2"><font color=blue>欢迎进入博客登录系统<br/>请输入你的用户名和密码</font></td></tr><tr><td>用户名:</td><td><input type="text" name="uname"/><font color=blue>${requestScope.error1}</font></td></tr><tr><td>密码:</td><td><input type="password" name="upassword"/><font color=blue>${requestScope.error2}</font></td></tr><tr><td align="center" colspan="2"><input type="submit" value="登录" class="btn"><input type="reset"  value="重置" class="btn"></td></tr></table></form>
<pre name="code" class="html"><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"id="WebApp_ID" version="2.5"><servlet><servlet-name>CheckLogin</servlet-name><servlet-class>com.CheckLogin</servlet-class></servlet><servlet-mapping><servlet-name>CheckLogin</servlet-name><url-pattern>/checklogin</url-pattern></servlet-mapping></web-app>


<pre name="code" class="html">以上例子中 form表单中的action属性的值是"checklogin",这个值来自web.xml中的配置信息<span style="font-family: Arial, Helvetica, sans-serif;"><url-pattern>/checklogin</url-pattern>,去掉/,然后与剩下的保持一致就可以了</span>
<span style="font-family:Arial, Helvetica, sans-serif;"></span><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; border: 0px; line-height: 18px; font-family: Verdana, Arial, 宋体;"><a target=_blank href="http://www.w3school.com.cn/tags/att_form_action.asp">点击打开链接</a></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; border: 0px; line-height: 18px; font-family: Verdana, Arial, 宋体;">action的值是一个url,表明是向何处发送表单数据。</p><p style="margin-top: 12px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; border: 0px; line-height: 18px; font-family: Verdana, Arial, 宋体;">可能的值:</p><ul class="listintable" style="margin: 20px; padding: 0px; border: 0px; list-style-type: none; font-family: Verdana, Arial, 宋体;"><li style="margin: 0px; padding: 0px; border: 0px; list-style-type: disc;">绝对 URL - 指向其他站点(比如 src="www.example.com/example.htm")</li><li style="margin: 0px; padding: 0px; border: 0px; list-style-type: disc;">相对 URL - 指向站点内的文件(比如 src="example.htm")</li></ul>

                                             
0 0