可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
This question already has an answer here:
The xml file is located in WebContent/WEB-INF/web.xml of my project. I am using Eclipse and running Tomcat (which is not installed via Eclipse. I prefer it to be a separate installation).
EmployeeManagementindex.htmlindex.htmindex.jspdefault.htmldefault.htmdefault.jspnamePramodRegistration/EmployeeManagement/WebContent/Registration
It doesnt work when the form page submits to the servlet. I am getting a 404 error everytime. I have been encountering this problem for a while. Somebody please help me.
回答1:
You are missing ... tag which is important to mapping. So use following :
EmployeeManagementindex.htmlindex.htmindex.jspdefault.htmldefault.htmdefault.jspnamePramodRegistrationcom.yourPackageName.yourServletNameRegistration/EmployeeManagement/WebContent/Registration
and you should give action value on your form like following:
and also note it down all values are case sensitive on the following code:
Registrationcom.yourPackageName.yourServletNameRegistration/EmployeeManagement/WebContent/Registration
Your servlet name Registration should be same on both tags ... and ... and also package name should be same where your servlet class is located.
回答2:
you have not mapped servlet name to servlet class, It should be like given below,
In give the path of your servlet
Registrationcom.RegistrationRegistration/EmployeeManagement/WebContent/Registration
回答3:
Check your form action. Is the path there
/EmployeeManagement/WebContent/Registration
or
YOURAPPCONTEXT/EmployeeManagement/WebContent/Registration
or
YOURAPPNAME/EmployeeManagement/WebContent/Registration
回答4:
You have specifyed a servlet-mapping and used the name Registration in servlet-name without defining it before.
You need to define the servlet before using it in a servlet mapping
Registration[fully qualifyied name of your servlet]
回答5:
You are missing another part to define the servlet in the web.xml
Registration package.path.to.RegistrationServlet
回答6:
You forgot a vital part of the configuration. You should add this to your web.xml before servlet-mapping tag:
Registrationcom.name.of.your.servlet.class