<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>com.UploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/go</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
当我使用/go作为URL模式时,它正在工作。当我将其更改为其他名称时,它不是/servletgo。如何更改它.xml文件?
我得到了答案。
我们在html文件中写的"操作"是在.xml文件下的url-pattern中写的。
例如:
我的html代码:
<html>
<body>
<form action="welcome" method="post" enctype="multipart/form-data">
Select File:<input type="file" name="fname"/><br/>
<input type="submit" value="upload"/>
</form>
</body>
</html>
</html>
and my servlet code:
<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>com.UploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/welcome</url-pattern> //we have to use same pattern what we noted in html action.If we change the action name in html,then only we can change the url- pattern.
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>