一般的路径是/web应用名称/jsp路径/jsp名称

解决方案 »

  1.   

    我的String url="/myweb/showRst.jsp";
    在testServ工程下,showRst.jsp在mvcTest\myWeb目录下,myservlet.java在src.cn.com.my目录下,以上的url写法有问题吗?
      

  2.   

    /mvcTest/myWeb/showRst.jsp
    /myweb/showRst.jsp
    /showRst.jsp三个都试试,总会有一个会对的。
      

  3.   

    就是这样了:/mvcTest/myWeb/showRst.jsp
    搂主真的会给分吗?
      

  4.   

    请用绝对地址,而不要用相对地址用http://xxx/xxx/xx.jsp的方式因为servlet和jsp是相互独立的,servlet根本不知道你的那个jsp页面在哪里,它只是单纯的被调用
      

  5.   

    老兄们,其实每一个可能的路径我都试过了,但就是不对呀,
    /mvcTest/myWeb/showRst.jsp
    /myweb/showRst.jsp
    /showRst.jsp
    不过向别的servlet转换是可以的。
    以下是我的servlet源代码:
    package com.test.servlet;import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;public class myServlet extends HttpServlet {
      private static final String CONTENT_TYPE = "text/html; charset=GBK";
      //Initialize global variables
      public void init(ServletConfig config) throws ServletException
      {
      //servletContext = config.getServletContext();
    super.init(config);
      }
      //Process the HTTP Get request  //Process the HTTP Post request
      public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
      {
        //response.setContentType(CONTENT_TYPE);
        //PrintWriter out = response.getWriter();
        //String name=request.getParameter("name");
        /*out.println("<html>");
        out.println("<head><title>myServlet</title></head>");
        out.println("<body bgcolor=\"#ffffff\">");
        out.println("<p>The servlet has received a POST. This is the reply.</p>");
        out.println("</body></html>");*/
        String url="/myWeb/showRst.jsp";
        //RequestDispatcher rd =request.getRequestDispatcher(url);
        ServletContext sc = getServletContext();
        RequestDispatcher rd =sc.getRequestDispatcher(url);
        //response.sendRedirect("http://localhost:8080/myWeb/showRst.jsp");
        rd.forward(request,response);
      }
      //Clean up resources
      public void destroy() {
      }
    }
      

  6.   

    放http://xxx/xxx/xx.jsp这种绝对路径也是不对 的