我在springmvc应用程序中使用ModelAndView对象传递了文件名。但是我无法解决这个编译问题。我是WEB开发的新手。
以下是我的jsp页面的内容。
<% String pageRed = "static/" + (String)request.getAttribute("redPage"); %>
<%@ include file="<%=pageRed %>" %>
Include File Line给出以下错误
Multiple annotations found at this line:
- Start tag (<jsp:directive.include>) not closed properly, expected '>'.
- A file value is required in this directive
- Invalid location of text ("<%=pageRed %>" %) in tag
(<jsp:directive.include>).
知道吗?
您不应该使用<%@include file="<%=pageRed%>"%>
可以使用而不是
<jsp:include page="static/${redPage_name}.jsp" />
这对我来说是工作
祝好运
您无法执行此操作,因为include指令是在servlet转换时间期间解析的,而(String)request.getAttribute("redPage");
是在运行时解析的。
这样做的原因是什么?