Java SpringMVC中带有可变文件名的Jsp Include File指令
我在SpringMVC应用程序中使用ModelAndView对象传递了文件名。但我无法解决这个编译问题。我是网络开发新手 以下是我的jsp页面的内容Java SpringMVC中带有可变文件名的Jsp Include File指令,java,jsp,include,Java,Jsp,Include,我在SpringMVC应用程序中使用ModelAndView对象传递了文件名。但我无法解决这个编译问题。我是网络开发新手 以下是我的jsp页面的内容 <% String pageRed = "static/" + (String)request.getAttribute("redPage"); %> <%@ include file="<%=pageRed %>" %> Include File行出现以下错误 Multiple annotations
<% String pageRed = "static/" + (String)request.getAttribute("redPage"); %>
<%@ include file="<%=pageRed %>" %>
Include File行出现以下错误
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指令是在servlet转换期间解析的,而
(String)request.getAttribute(“redPage”)代码>在运行时得到解析
这样做的原因是什么 您不应该使用
可以使用代替
<jsp:include page="static/${redPage_name}.jsp" />
这是我的工作
祝你好运