简体   繁体   中英

Can servlets have extensions?

I have a page http://domain.com/servlets/projecta?action=cust_active

but need to provide a link to the same place with an extension (like .jsp or something).

Is there a way to add an extension to this, but have it still load the same way?

You would need multiple URL mappings for your servlet in web.xml. Assuming that your existing servlet is mapped to projecta like this:

  <servlet-mapping>
    <servlet-name>servlet</servlet-name>
    <url-pattern>/projecta</url-pattern>
  </servlet-mapping>

You might need:

  <servlet-mapping>
    <servlet-name>servlet</servlet-name>
    <url-pattern>/projecta</url-pattern>
    <url-pattern>/projecta.ext</url-pattern>
  </servlet-mapping>

Also see this in case your servlet version is different: many url-pattern for the same servlet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM