web3.0——Tomcat启动报错以及web.xml文件的配置

版权声明:为中华之崛起而读书。转载请注明出处: https://blog.csdn.net/Kj_Gym/article/details/83447627

一、Eclipse中启动tomcat报错。

——Server Tomcat v8.5 Server at localhost failed to start
原因:Servlet类是使用Eclipse自动生成的,这时候,Eclipse会自动添加@WebServlet("/类名Servlet");这时候不需要在web.xml中添加类似如下代码了。

<servlet-mapping>
<servlet-name>Servlet类名</servlet-name>
<url-pattern>/Servlet类名</url-pattern>
</servlet-mapping>

解决方法: 删除自己在web.xml中写的,或者删除@WebServlet("/类名Servlet");即可。
注意: 如果是自动生成的这种,假如是在login.jsp的form提交来的,那么在form的action属性设置时为

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

不能设置为

<form action="/LoginServlet" method="post">

更多详细内容见
https://blog.csdn.net/xulianboblog/article/details/51079534

二、一个详细讲述web.xml的博客

web.xml配置详解-----转载自博客园https://www.cnblogs.com/ClassNotFoundException/p/6641867.html

猜你喜欢

转载自blog.csdn.net/Kj_Gym/article/details/83447627