Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SpringMVC中带有可变文件名的Jsp Include File指令_Java_Jsp_Include - Fatal编程技术网

Java SpringMVC中带有可变文件名的Jsp Include File指令

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

我在SpringMVC应用程序中使用ModelAndView对象传递了文件名。但我无法解决这个编译问题。我是网络开发新手

以下是我的jsp页面的内容

<% 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" />

这是我的工作

祝你好运