亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - jsp跳轉(zhuǎn)到servlet,出現(xiàn)404
巴扎黑
巴扎黑 2017-04-18 10:54:13
0
3
782

從網(wǎng)上下了一個小項(xiàng)目,其中一段代碼不刪除或者注釋掉,服務(wù)器就會啟動失敗。如圖所示:

注釋之后,服務(wù)器能正常啟動,但是jsp跳轉(zhuǎn)失敗。

具體代碼和配置如下:

form

xml

項(xiàng)目結(jié)構(gòu)


哪里有錯誤呢?

巴扎黑
巴扎黑

reply all(3)
Peter_Zhu

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" 是因?yàn)?@WebServlet是Servlet3.0規(guī)范所支持的一種簡化配置,他和你在 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
  1. 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

  2. Configuration in the formaction中指定的url 與 web.xml中配置的Servlet 不匹配,按照web.xml, your action should be written like this

<form action="/ServletLearningChapter1_3/LoginServlet" ...>
大家講道理

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template