一、<form action="Test/Login" method="post">

在action中有两种表示方式:

1、"/Test/Login"  说明是相对于web服务器的根目录,可以理解为  http://localhost:8080/Test/Login

2、“Test/Login”  说明是相对于当前web应用程序的根目录,可以理解为  http://localhost:8080/项目名称/Test/Login

二、@WebServlet(name="Login",urlPatterns={"/Test/Login"})

urlPatterns与<url-pattern>的作用相同

urlPatterns代表了servlet的路径,即当URI为:http://localhost:8080/项目名称/Test/Login?name=""时,web容器会调用名字为Login的servlet为用户提供服务。

所以说action是与urlPatterns相对应的,即action中的URL需要填写urlPatterns中的URL。

再额外记录几点:

1、当html在webroot/html文件夹时,action中的URL需要为“../Test/Login”表示将路径改到"http://localhost:8080/项目名称/"下,否则URL将为“http://localhost:8080/项目名称/html/Test/Login”

2、当urlPatterns={"/Test/Login"}时,如果要在其修饰的servlet中使用response.sendRedirect(url),URL会为http://localhost:8080/项目名称/Test/url,即在Test/下添加了url。这是就需要根据实际情况,令url="../"+url。

form中的action与<url-pattern>的理解的更多相关文章

  1. spring中action和url的对应关系

    spring 中, action和url的对应关系             在web.xml中,这样配置:           <servlet-mapping >             ...

  2. HTML form表单中action的正确写法

    我的Java Web Application的context是myweb,即http://localhost:8080/myweb/index.jsp是欢迎页. 现在我的一个Controller的映射 ...

  3. jQuery中设置form表单中action的值的方法

    下面介绍在jQuery中设置form表单中action的值的方法. $("#myFormId").attr("action", "userinfo.s ...

  4. jQuery中设置form表单中action值与js有什么不同。。。。

    jQuery中设置form表单中action值与js有什么不同.... HTML代码如下: <form action="" method="post" i ...

  5. struts2中form提交到action中的中文参数乱码问题解决办法(包括取中文路径)

    我的前台页是这样的: <body>      <form action="test.action" method="post">     ...

  6. jQuery中设置form表单中action值的方法

    jQuery中设置form表单中action值的方法 (2011-03-17 10:18:19) 转载▼ 标签: 杂谈   html代码: <form id="myFormId&quo ...

  7. Form表单中的action路径问题,form表单action路径《jsp--->Servlet路劲问题》这个和上一个《jsp--->Servlet》文章有关

    Form表单中的action路径问题,form表单action路径 热度5 评论 50 www.BkJia.Com  网友分享于:  2014-08-14 08:08:01     浏览数44525次 ...

  8. (20)odoo中的action

    ---------更新时间18:06 2016-09-18 星期日15:05 2016-03-14 星期一18:07 2016-02-19 星期五---------* 窗口动作   <?xml ...

  9. web form中自定义HttpHandler仿mvc

    web form中自定义HttpHandler仿mvc 前言 在mvc大行其道的今天,仍然有不少公司的项目还是使用web form来实现的(其实mvc也是基于web form的),如果要在项目中引入m ...

随机推荐

  1. atcoder 2579

    You are taking a computer-based examination. The examination consists of N questions, and the score ...

  2. Ubuntu wubi.exe 安装到Windows 正在下载ubuntu-11.04-desktop-i386.iso

    下载一个Ubuntu的iso镜像,用虚拟光驱加载后,点击 wubi.exe->安装到Windows 设置好后,进入安装,又自动开始下载iso镜像了,提示:正在下载ubuntu-11.04-des ...

  3. C语言把字符串转换为数字

    C当中有一些函数专门用于把字符串形式转换成数值形式. printf()函数和sprintf()函数 -->通过转换说明吧数字从数字形式转换为字符串形式: scanf()函数把输入字符串转换为数值 ...

  4. ST表(查询区间最值问题)

    ST表与线段树相比,这是静态的,无法改动,但是他的查询速度比线段树要快,这是牺牲空间换时间的算法. O(nlogn)预处理,O(1)查询.空间O(nlogn). ][]; ]; void rmq_in ...

  5. POJ3368

    http://poj.org/problem?id=3368 给出一个升序数组和 q 个查询.对每个查询,返回 a b 之间出现次数最多的那个元素的出现次数. 这一类区间查询的问题很容易想到用线段树来 ...

  6. lnmp 架构

    Mysql安装 tar zxf mysql-boost-5.7.17.tar.gz yum install -y gcc gcc-c++ yum install cmake-2.8.12.2-4.el ...

  7. tp 查询

  8. centos7安装与卸载软件

    安装 yum install 服务名 查看服务名 rpm -qa |grep -i aerospike 或者 yum list installed | grep aerospike 卸载 yum re ...

  9. .net core项目中引用.net framework封装的dll库

    https://blog.csdn.net/sharphou/article/details/80746551   A----------如何安装IIS [Server Hosting]------- ...

  10. Git命令行中文显示错误

    中文文件名乱码(git status.git log.git pull .git push) #不对0x80以上的字符进行quote,解决git status/commit时中文文件名乱码git co ...