Servlet-mapping Url-pattern/and/* differences

Source: Internet
Author: User

A servlet was customized

1. First we write in Web. xml

And then start the project we open http://localhost:8080 this time we can forward index.jsp through the servlet,

Then I changed the servlet inside index.jsp to index.html, then the error, and then the cycle of death,

Then I changed the Web. XML to/* so that direct access no matter whether the servlet is index.jsp or index.html is a dead loop.

Then understand/and/* intercept for the requested request, but/for the. JSP does not intercept. For why the JSP does not intercept, this should be inside the Web container control. And then looked at Tomcat's web. XML configuration file

Inside, he has 1 default servlets,

And then how do we get him to visit the Web. XML if we write/* This, then we'll write

That's all you can do.

Then we don't care whether/or/*, we want to access the static page, then we write this in Web. XML, and then forward the time can be the static page, do not go servlet, when forwarding remember to write absolute path OH

Servlet-mapping Url-pattern/and/* differences

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.