[英]Can servlets have extensions?
I have a page http://domain.com/servlets/projecta?action=cust_active 我有一个页面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). 但需要提供带有扩展名的同一个地方的链接(如.jsp或其他)。
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. 您需要在web.xml中为servlet建立多个URL映射。 Assuming that your existing servlet is mapped to
projecta
like this: 假设您现有的servlet映射到
projecta
如下所示:
<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 如果你的servlet版本不同,也请看这个: 同一个servlet的许多url-pattern
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.