jsp submit to Servlet report 404 error problem to resolve of webroot subdirectory

  • 2020-06-07 05:08:52
  • OfStack

The first time I wrote something with jsp, I wrote jsp under webroot subfolder. When I submitted to Servlet Times 404 error, I always thought it was a subfile problem, but it was not.

The fact is that the jsp file can't find the root directory,
 
<% 
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%> 
<base href="<%=basePath%>"> 

Oh, this situation is very strange, for the novice is absolutely painful ah.

Related articles: