HTTP Status 404-/servlet/item/additemservlet

Source: Internet
Author: User

I want to learn programming people are very familiar with 404 and 500 are very sensitive. I encountered these two errors many times while making the DRP system, so I met him today and let me remember him, that is a "/":

This is to say that JSP problem, and can not find, learn Java students know Servlet/item is I set up a servlet after a virtual folder. The configuration files are written like this:

        <servlet><servlet-name>AddItemServlet</servlet-name><servlet-class> Com.bjpowernode.drp.basedata.web.additemservlet</servlet-class></servlet><servlet-mapping> <servlet-name>additemservlet</servlet-name><url-pattern>/servlet/item/additemservlet</ Url-pattern></servlet-mapping>
The above configuration file is not a problem, the following is my JSP is more critical and easy error, and I went wrong place: path problem

<body class= "body1" ><form name= "Itemform"  id= "Itemform" action= "<span style=" Background-color:rgb ( 255, 0, 0); " >/servlet/item/AddItemServlet</span> "method=" POST "onsubmit=" return Validateform (This) ">
This red place seems to be no problem, is to request the servlet, but when I click on the button to jump, but error, this is added "/"And not to add"/"The difference, because I added the BasePath (recommended blog) in the JSP, that is, the Web full path:      

<%string path = Request.getcontextpath (); String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";%>
Path-------------------------------------------------------/servlet/item/additemservlet

BasePath---http+://+localhost+:+8181+/servlet/item/additemservlet+/(http://localhost:8181/servlet/item/additemservlet)

And I added "/" to the code and then the address becomes http://localhost:8181//Servlet/item/additemservlet

So we can see a "/" we can not ignore, which has become a problem in my future experience. Share the ~ ~

HTTP Status 404-/servlet/item/additemservlet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.