在更改Servlet的url-pattern时未呈现HTML页面

时间:2017-09-05 15:57:10

标签: java tomcat servlets

Home.java文件

RequestDispatcher view = request.getRequestDispatcher("/WEB-
    INF/views/Login.html");
view.include(request, response);

web.xml文件

这有效 -

<servlet>
  <servlet-name>Home</servlet-name>
  <servlet-class>home.Home</servlet-class>
 </servlet>

 <servlet-mapping>
  <servlet-name>Home</servlet-name>
  <url-pattern>/home</url-pattern>
 </servlet-mapping>

这不起作用 -

<servlet>
  <servlet-name>Home</servlet-name>
  <servlet-class>home.Home</servlet-class>
 </servlet>

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

在第二种情况下,控制台中存在重复错误打印。

SEVERE: Servlet.service() for servlet [Home] threw exception
java.lang.StackOverflowError
    at javax.servlet.ServletRequestWrapper.isAsyncStarted(ServletRequestWrapper.java:409)
    at javax.servlet.ServletRequestWrapper.isAsyncStarted(ServletRequestWrapper.java:409)
    at javax.servlet.ServletRequestWrapper.isAsyncStarted(ServletRequestWrapper.java:409)

我在stackoverflow上发现了关于相同错误的问题,但我无法理解其中的任何错误

java.lang.StackOverflowError being thrown by class that doesn't exist

Faces Servlet threw exception java.lang.StackOverflowError

0 个答案:

没有答案