Solve the problem first. The reason for your jsp jump failure is indeed as Ethan said. The url specified by the action in the form does not match the Servlet configured in web.xml. Just write it as "/ServletLearningChapter1_3/LoginServlet" and it will be fine
In addition, in terms of expansion, the reason why the code you see on the Internet uses action 值写做 "/LoginServlet" 是因为 @WebServlet是Servlet3.0规范所支持的一种简化配置,他和你在 web.xml 中配置 <servlet><url-pattern>/LoginServlet</url-pattern></servlet> is a function.
So when you comment out @webServlet, the value of url mapping should be based on web.xml.
Finally, if you report an error, I hope you can type out the specific information next time. Otherwise, because we don’t have your environment information, we won’t be able to guess the specific problem.
LoginServlet should be written in a certain framework. When the framework jar package is missing or the configuration is incorrect, the annotation will report an error and cause the startup to fail
Configuration in the formaction中指定的url 与 web.xml中配置的Servlet 不匹配,按照web.xml, your action should be written like this
The poster asked two questions and took a rough look at it. Visual inspection: Question 1: Are the definitions repeated? Question 2: The project path is missing? Not necessarily correct
Solve the problem first. The reason for your jsp jump failure is indeed as Ethan said. The url specified by the action in the form does not match the Servlet configured in web.xml. Just write it as
"/ServletLearningChapter1_3/LoginServlet"
and it will be fineIn addition, in terms of expansion, the reason why the code you see on the Internet uses
action
值写做"/LoginServlet"
是因为@WebServlet
是Servlet3.0规范所支持的一种简化配置,他和你在 web.xml 中配置<servlet><url-pattern>/LoginServlet</url-pattern></servlet>
is a function.So when you comment out
@webServlet
, the value of url mapping should be based on web.xml.Finally, if you report an error, I hope you can type out the specific information next time. Otherwise, because we don’t have your environment information, we won’t be able to guess the specific problem.
Well, that’s it, wish you well :D
Two questions:
The annotation on
LoginServlet
should be written in a certain framework. When the framework jar package is missing or the configuration is incorrect, the annotation will report an error and cause the startup to failConfiguration in the form
action
中指定的url 与web.xml
中配置的Servlet
不匹配,按照web.xml
, your action should be written like thisThe poster asked two questions and took a rough look at it. Visual inspection:
Question 1: Are the definitions repeated?
Question 2: The project path is missing?
Not necessarily correct