Mapping servlet in web.xml [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:54:01

问题:

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:

//Some code here

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!