jstl模板引擎1.0.8发布

============ 1.0.8
1. 增加TryCatchFinally支持
2. 增加com.skin.ayada.jstl.sql.ConnectTag  <sql:connect/>
3. 增加com.skin.ayada.jstl.sql.SqlTag      <sql:execute/>
4. 增加com.skin.ayada.jstl.sql.QueryTag    <sql:query/>
5. 增加com.skin.ayada.jstl.io.CopyTag      <io:copy/>
6. 增加com.skin.ayada.jstl.io.DeleteTag    <io:delete/>
7. 增加com.skin.ayada.jstl.io.MakeDirTag   <io:mkdir/>
8. 修复编译模式下自定义Tag的setXXX方法编译错误


命令行下运行: com.skin.ayada.template.Main "webapp\command.jsp" "UTF-8"


对应的demo和test页面参看: /webapp/command.jsp

<%@ page contentType="text/html;charset=UTF-8"%>
<c:if test="${1 == 2}">
    <io:copy   file="E:/WorkSpace/ayada/webapp/test1" todir="E:/WorkSpace/ayada/webapp/test2"/>
    <io:delete file="E:/WorkSpace/ayada/webapp/test2/style.css"/>
    <io:mkdir  file="E:/WorkSpace/ayada/webapp/test2/empty1"/>
    <io:mkdir  file="E:/WorkSpace/ayada/webapp/test2/empty2"/>
    <io:delete file="E:/WorkSpace/ayada/webapp/test2/empty2"/>
    <c:exit test="${1 == 1}"/>
</c:if>

<h1>sql:execute</h1>
<h2>connection</h2>
<p>1. get from attribute, example: connection="[expression]"</p>
<p>2. get from pageContext by name: connection</p>
<p>3. get from parent tag</p>
<p>4. throws exception</p>

<p>template.home: ${template.home}</p>

<!-- use external connection -->
<sql:connect var="connection2" connection="${myConnection}"></sql:connect>

<sql:connect var="connection" url="jdbc:mysql://localhost:3306?user=root&password=1234&characterEncoding=utf8" driverClass="com.mysql.jdbc.Driver">
    <sql:execute out="${pageContext.getOut()}">
        drop database if exists mytest2;
        create database mytest2 character set utf8;
    </sql:execute>
</sql:connect>

<sql:connect var="connection" url="jdbc:mysql://localhost:3306/mytest2?user=root&password=1234&characterEncoding=utf8" driverClass="com.mysql.jdbc.Driver">
    <sql:execute home="${template.home}/database" file="create.sql" encoding="UTF-8" out="${pageContext.getOut()}"/>
    <sql:execute sql="delete from my_test1;" out="${pageContext.getOut()}"/>
    <sql:execute sql="delete from my_test2;" out="${pageContext.getOut()}"/>
    <sql:execute sql="insert into my_test2(my_id, my_code, my_name) values (1, '1', '1');"/>

    <sql:execute out="${pageContext.getOut()}">
        <c:forEach items="1, 2, 3, 4, 5" var="id">
            insert into my_test1(my_id, my_code, my_name) values (${id}, '${id}', '${id}');
        </c:forEach>
        <c:forEach items="1, 2, 3, 4, 5" var="id">
            insert into my_test2(my_id, my_code, my_name) values (${id}, '${id}', '${id}');
        </c:forEach>
    </sql:execute>

    <sql:execute out="${pageContext.getOut()}">
        delete from my_test2;
        insert into my_test2(my_id, my_code, my_name) values (1001, '1001', '1001');
        insert into my_test2(my_id, my_code, my_name) values (1002, '1001', '1001');
        insert into my_test2(my_id, my_code, my_name) values (1003, '1001', '1001');
        insert into my_test2(my_id, my_code, my_name) values (1004, '1001', '1001');
        insert into my_test2(my_id, my_code, my_name) values (1005, '1001', '1001');
        insert into my_test2(my_id, my_code, my_name) values (1006, '1001', '1001');
        insert into my_test2(my_id, my_code, my_name) values (1007, '1001', '1001');
        insert into my_test2(my_id, my_code, my_name) values (1008, '1001', '1001');
    </sql:execute>

    <sql:execute connection="${connection}" sql="insert into my_test2(my_id, my_code, my_name) values (1009, '1001', '1001');"/>

    <table>
        <tr>
            <td>id</td>
            <td>userName</td>
            <td>nickName</td>
        </tr>
        <sql:query var="resultSet" sql="select * from my_test2 where my_id > 1001" offset="2" length="3">
        <tr>
            <td>${resultSet.getLong("my_id")}</td>
            <td>${resultSet.getString("my_code")}</td>
            <td>${resultSet.getString("my_name")}</td>
        </tr>
        </sql:query>
    </table>
</sql:connect>

下载地址:  https://github.com/xuesong123/java-template

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值