html的简单渲染介绍
public static string render(string phtmltemplate, final map pmodel) {
propertyplaceholderhelper placeholderhelper = new propertyplaceholderhelper("${", "}");
string result = placeholderhelper.replaceplaceholders(phtmltemplate, new placeholderresolver() {
@override
public string resolveplaceholder(string placeholdername) {
return objects.tostring(pmodel.get(placeholdername), "");
}
});
return result;
}
上面的方法返回一个携带数据的html, 这样前端js 就不用等到ajax数据之后再渲染.
注: propertyplaceholderhelper中 有一句
1 propval = parsestringvalue(propval, placeholderresolver, visitedplaceholders);
这句代码会去解析model中的value. 一般不需要, 可以把它注释掉.
我的实践是: spring+vuejs+html 的一个web实例.(不用jsp或其它html模板)
以上就是html的简单渲染介绍的详细内容。