我尝试包含'home.jsp'文件或'error.jsp'文件。这是我的servlet文件和我的模板:
// 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
答案 0 :(得分:0)
错误很明显。
main.jsp
期待您必须传递的参数
使用jsp:param
或querystring main.jsp?name=value