JSP Site web.xml issue Page not found for url-pattern /MyController in sevlet-mapping
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>MyController</servlet-name>
<servlet-class>com.pk.MyController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyController</servlet-name>
<url-pattern>/MyController</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-开发者_运维百科file>
</welcome-file-list>
</web-app>
I have this configuration, but unable to access hzhfyp.com/MyController
(PAGE NOT FOUND
)
The Path for MyController
servelet is WEB-INF/classes/com/pk/MyController.class
Although index.jsp
is loaded accuratelty. Demo here http://hzhfyp.com/
Clicking any button will generate js error visible in Firebug(firefox) as Page not Found.
URLs are case sensitive. You've mapped it on /MyController
with M
, but your jQuery code is calling it by /myController
with m
. Fix it accordingly.
As to the servlet returing a 404 in spite of the correct URL, this can happen when the servlet failed to initialize or when you didn't deploy the correct web.xml
at all. Read the server startup logs for any errors during servlet initialization and verify if you're deploying with the right web.xml
.
精彩评论