1.Beetl使用
只针对springmvc;
Beetl(Ctrl+鼠标左键点击链接下载,进入网站后请耐心等待下载弹出框);
Beetl插件 同上点击下载;
1.1 配置Beetl
多视图配置请查看API文档
<bean id="beetlConfig" class="org.beetl.ext.spring.BeetlGroupUtilConfiguration" init-method="init">
</bean>
<bean id="viewResolver" class="org.beetl.ext.spring.BeetlSpringViewResolver">
<property name="prefix" value="/page/"/>
<property name="suffix" value=".html"/>
<!--
<property name="order" value="0"/>
<property name="config" ref="beetlConfig"/>
-->
<property name="contentType" value="text/html;charset=UTF-8"/>
</bean>
1.2 Controller代码
@Controller
@RequestMapping("test")
public class TestController {
@RequestMapping("/getest")
public ModelAndView test(){
List<Sms> smslist=new ArrayList<Sms>();
try {
for (int i = 0; i < 10; i++) {
Sms sms=new Sms();
sms.setSmsPhone("18251968099");
sms.setSmStatus(1);
sms.setSmsContext("【江苏首屏】 明天休息!");
smslist.add(sms);
}
} catch (Exception e) {
e.printStackTrace();
}
return new ModelAndView("test","smslist",smslist);
}
}
1.3html代码
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<script src="/resources/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
alert($('table tr:eq(0) td:eq(0)').html());
});
</script>
<head>
<body>
<table>
<tr>
<td>手机号</td>
<td>内容</td>
<td>状态</td>
</tr>
<%for(sms in smslist){%>
<tr>
<td>${sms.smsPhone}</td>
<td>${sms.smsContext}</td>
<td>${sms.smStatus}</td>
</tr>
<%}%>
</table>
</body>
</html>
2.插件使用
注:插件内含使用说明书;
解压拷贝beetl-eclipse-plugin_1.0.0.201506072245.jar放到eclipse下dropins文件夹下,比如D:\eclipse\dropins
3.Beetl使用说明书
4.异常
启动程序可能会抛出
java.lang.ClassNotFoundException: org.antlr.v4.runtime.CharStream
解决方法:缺少antlr4-runtime.jar 包,点击下载。