简体   繁体   English

如何使用Struts 1标签检查文件是否存在?

[英]How to check file existence using Struts 1 tags?

I need to check if the html file is present on certain path, if not, a message needs to be displayed. 我需要检查某个路径上是否存在html文件,如果没有,则需要显示一条消息。

Is there any tag definition in Struts 1 which facilitates to check file existence? Struts 1中是否有任何标签定义有助于检查文件是否存在?

//filePath taken from bean variable on struts
boolean fileExists = new java.io.File(getServletContext().getRealPath("/")+java.io.File.separator+filepath).exists();
if(fileExists)
{
%>
<jsp:include page='<%=correct.toString()%>' /> <br />
<%
}
else
{   
%>
<jsp:include page='<%="/html/error/error.html"%>' /> <br />
<%
}
%>

A strategy of this kind works. 这种策略有效。 The purpose of asking this question was only to research whether struts offers such concept. 提出这个问题的目的只是研究struts是否提供这样的概念。 Unfortunately, some reviewers demoted this question to negative. 不幸的是,一些评论家将这个问题降为负面。 Really disgusting platform stackoverflow is wrt knowledge gathering. 非常恶心的平台stackoverflow是知识收集。

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

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