我写了一个jsp的登入界面<form action="LoginClServlet" method=post>把他放在项目mywebjsp目录的web3下,web3同一级的有WEB-INF。由于Servlet文件只能放在WEB-INF/classes目录下。而jsp文件则放在WEB-INF的同一级,所有建了web3(存放jsp),当然我也把servlet部署了且url为
<url-pattern>/LoginClServlet</url-pattern>,这时jsp通过action=“LoginClServlet",访问不到servlet,怎么办??/??各位大神。。访问登入界面http://localhost:8080/mywebjsp/web3/login.jsp。
提交后url为http://localhost:8080/mywebjsp/web3/LoginClServlet ,而访问我的LoginClServlet的url应该是http://localhost:8080/mywebjsp/LoginClServlet 。怎么办???

解决方案 »

  1.   

    看这个:
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        你加了吗?
      

  2.   

    1、首先确认servlet的URL配置正确看http://localhost:8080/mywebjsp/LoginClServlet是否可访问
    2、相对路径使用action=“LoginClServlet"改为action=“../LoginClServlet"或者action=“../../LoginClServlet"多试几次../意为上级目录