我试图从JSP页面调用Servlet。
的index.jsp:
<a href="VisitServlet">Visit</a>
目录结构:
Web Page --> Pages --> HomePage --> index.jsp
Source Packages --> servlets.a.b.VisitServlet.java
的web.xml:
<servlet>
<servlet-name>VisitServlet</servlet-name>
<servlet-class>servlets.a.b.VisitServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VisitServlet</servlet-name>
<url-pattern>/VisitServlet</url-pattern>
</servlet-mapping>
我收到此错误:
HTTP Status 404 - Not Found
答案 0 :(得分:2)
尝试使用:
<a href="${pageContext.request.contextPath}/VisitServlet">Visit</a>