繁体   English   中英

无法包含JSP文件

[英]Unable to include a JSP file

我正在尝试检查文件是否存在,然后如果为true ,则包括JSP文件。 但是我从下面的代码中得到错误。

令牌上的语法错误,请删除这些令牌

file.handler无法解析为类型

令牌“ =”上的语法错误。 预期

这是我的代码:

String uri = request.getRequestURI();
String pageName = uri.substring(uri.lastIndexOf("/")+1);
String filename = pageName.replace(".jsp", "");

String path = request.getServletPath();  
path = path.replace( pageName , "");

String handler=path+"handler/"+filename+"_handler.jsp";

if(null != application.getResource(handler)){
    <%@include file="${handler}"%>
}

我是一名PHP程序员,但对JSP还是陌生的。 请指教

您可以尝试调度员包括资源

if(null != application.getResource(handler)){
    request.getRequestDispatcher(handler).include(request, response);
}

尝试使用JSP表达式,例如:

<%@include file="<%=handler %>" %>

<jsp:include page="${handler}"/>呢?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM