81,091
社区成员
发帖
与我相关
我的任务
分享
public class TemplateCls
{
public void ReplaceBlock(String s,String inFile)
{
Pattern pattern = Pattern.compile(s);
Matcher matcher = pattern.matcher(Templates);
//替换所有符合正则的数据
Templates = matcher.replaceAll(inFile);
System.out.println(Templates);
}
}
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="szw.TemplateCls;" %>
<%
TemplateCls oTemplate = new TemplateCls();
oTemplate.SetTemplateDir("http://192.168.1.45:8100/szwCMS/Template/");
oTemplate.SetTemplateFile("test.tpl");
String str = "中国";
oTemplate.ReplaceBlock("test",str);
out.write(oTemplate.Parse());
%>
public class Test{
String templates="testTest";
public void ReplaceBlock(String s,String inFile)
{
Pattern pattern = Pattern.compile(s);
Matcher matcher = pattern.matcher(templates);
//替换所有符合正则的数据
templates = matcher.replaceAll(inFile);
System.out.println(templates);
}
public static void main(String [] args){
new Test().ReplaceBlock("test", "中国");
}
}