繁体   English   中英

如何通过配置web.xml将URL模式从/index.jsp更改为/test/index.jsp?

[英]How to change the URL pattern from /index.jsp to /test/index.jsp by configuring web.xml?

我在根文件夹(webcontent)中有一个名为index.jsp jsp文件,直到现在我只是使用以下URL访问该页面:

HTTP://本地主机:8080 /采样/ index.jsp的

Sample是项目名称。

现在我被要求将URL模式更改为以下内容而不更改index.jsp文件的位置(即index.jsp仍然在webcontent文件夹下):

HTTP://本地主机:8080 /采样/测试/ index.jsp的

如何通过配置web.xml来实现这一目标?

这可以通过以下方式实现

  <servlet>
    <servlet-name>BeerAppServlet</servlet-name>
    <jsp-file>/index.jsp</jsp-file>
  </servlet>
  <servlet-mapping>
    <servlet-name>BeerAppServlet</servlet-name>
    <url-pattern>/test/index.jsp</url-pattern>
  </servlet-mapping>

<servlet>而不是将其映射到<servlet-class>将其映射到<jsp-file>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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