0

我尝试包含“home.jsp”文件或“error.jsp”文件。这是我的 servlet 文件和模板:

// 小服务程序

...
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{

            // api access
        Api apix  = new Api(new ApiRequest(-1));

        // post params
        String email = request.getParameter("email");
        String password = request.getParameter("password");

        // exists?
        User user =  apix.userManager.authenticate(email, password);

        // template
        String address = "/main.jsp";

                // variable content
        String content_page = "/WEB-INF/user/home.jsp";


        if (user == null)
        {
            content_page = "/error.jsp";
        }

        request.setAttribute("content_page", content_page);
        RequestDispatcher dispatcher = request.getRequestDispatcher(address);

        dispatcher.forward(request, response);


}

// main.jsp

<head>
    <jsp:include page="/head_includes.jsp"/>
</head>

<body>

    <% 
        String content_page = request.getParameter("content_page");

        if (content_page == null)
        {
            content_page = "/error.html";
        }

    %>

            <!-- I get an error here -->
            **<jsp:include page="<%= content_page %>">**
</body>

我在 Eclipse 上收到此错误:

org.apache.jasper.JasperException: /main.jsp (line: 29, column: 1) Expecting "jsp:param" standard action with "name" and "value" attributes
4

1 回答 1

0

错误很明显。

main.jsp期待您必须传递的参数

使用jsp:paramquerystring main.jsp?name=value

于 2012-12-10T03:53:50.420 回答