如何使用web.xml隐藏.jsp扩展名

时间:2015-02-20 13:24:05

标签: jsp tomcat

当我尝试此代码时,它会显示错误并停止执行代码。

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/WebApplication1"/>


<servlet>
<servlet-name>company</servlet-name>
<jsp-file>/companyDashboard.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>company</servlet-name>
<url-pattern>/companyDashboard</url-pattern>
</servlet-mapping>

1 个答案:

答案 0 :(得分:3)

在web.xml中定义映射

<servlet>
  <servlet-name>thejsp</servlet-name>
  <jsp-file>/thejsp.jsp</jsp-file>
</servlet>
<servlet-mapping>
   <servlet-name>thejsp</servlet-name>
   <url-pattern>/thejsp</url-pattern>
 </servlet-mapping>