📄 jspmaker.java
字号:
package com.jdon.cms.template;
import java.io.*;
import com.jdon.util.UtilValidate;
import com.jdon.util.FileUtil;
import com.jdon.util.PropsUtil;
import com.jdon.util.Debug;
import com.jdon.util.StringUtil;
import com.jdon.cms.xml.XmlUtil;
import com.jdon.cms.Constants;
/**
* xxx.jsp is :
* <tiles:insert definition="site.mainLayout" flush="true">
* <tiles:put name="body" value="xxxxxxxxxxxxxx" />
* </tiles:insert>
*
*
* <p>Company: </p>
* @author banq
* @version 1.0
*/
public class JspMaker {
private final static String module = JspMaker.class.getName();
private final static PropsUtil propsUtil = PropsUtil.getInstance();
/**
* get the content of JspTemplate.txt
* @return
*/
public static String getJspTemplateFile() {
String jspTemplateFilename = propsUtil.getProperty(Constants.
jspTemplateName);
String jspTemplateFile = propsUtil.getConfFile(jspTemplateFilename);
return jspTemplateFile;
}
/**
* make a new jsp for the new Page
* @param jspFileName
* @param htmlFilePath
* @return
*/
public static boolean generate(String jspPathName, String titleValue, String bodyValue) {
boolean success = false;
try {
String jspTemplateFile = getJspTemplateFile();
Debug.logVerbose("--> jspTemplateFile= " + jspTemplateFile + " jspPathName=" +
jspPathName, module);
if (! ( (UtilValidate.isNotEmpty(jspPathName)) &&
(UtilValidate.isNotEmpty(jspTemplateFile))))
return success;
String titleValue_Regex = propsUtil.getProperty(Constants.TITLEVALUE);
String bodyValue_Regex = propsUtil.getProperty(Constants.BODYVALUE);
String text = FileUtil.readFile(jspTemplateFile);
text = StringUtil.replace(text, titleValue_Regex, titleValue);
text = StringUtil.replace(text, bodyValue_Regex, bodyValue);
FileUtil.createFile(jspPathName, text);
success = true;
} catch (Exception ex1) {
Debug.logError(" File operate error:" + ex1, module);
return success;
}
return success;
}
public static void delete(String jspPathName){
try {
File file = new File(jspPathName);
if (file.exists()) {
file.delete();
}
} catch (Exception ex) {
Debug.logError("delete file:" + jspPathName + ex, module);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -