您的位置:首页 > 移动开发

Servlet , Servlet Mapping and Pattern the HTML

2011-09-11 22:00 267 查看
In the web.xml config file:

<servlet>

<servlet-name>Your Sevlet name</servlet-name>

<servlet-class>Your class </servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Your Sevlet name</servlet-name>

<url-pattern>/url</url-pattern>

</servlet-mapping>

In the HTML file:

<form  method="post" action="url">

</form>

Note:

1: The servlet-name in the two tags must be the same !

2: The url must be started with the '/', it stands for the webApp root directory . 

3: The url in the HTML file must be the same with in the web.xml, except the char '/'

For example:

If your web.xml file was :

<servlet-mapping>

<servlet-name>Your Sevlet name</servlet-name>

<url-pattern>/YangZhiYong1/YangZhiYong2/servlet</url-pattern> //The diretories is not limited.

</servlet-mapping>

so your HTML file must write as :

<form  method="post" action="YangZhiYong1/YangZhiYong2/servlet">

</form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐