view:https://github.com/icefairy/webplus
(or)view:https://git.oschina.net/icefairy/webplus
usage:
WPTemplateEngine desc:
welcome your code(pull request) and issue or starts
example:http://my.xlzbw.org:888/test
update:
2017-4-23 15:13:29
1.add initscanner auto scan all handler and add to server with actionkey defined in class_global sub
2.support:#MergeLibraries: false ,will copy depends library to objects\libs ,and will gen a bat file use to start the project(need java8 installed already);if you want regen the file just delete the bat file and run project from ide again;
3.add jarutils to support much function for class or jar like:GetAllClassesNames、GetAllClassesNamesFromJar、getClassProperties、getClassMethods、getClassByName、getpkgName、getSrcPath
4.add connectionstr demo and dbdriver
(or)view:https://git.oschina.net/icefairy/webplus
usage:
B4X:
'Handler class
Sub Class_Globals
Private te As WPTemplateEngine
End Sub
Public Sub Initialize
te.Initialize
End Sub
Sub Handle(req As ServletRequest, resp As ServletResponse)
te.bindResponse(resp)
te.putData("headertitle","WebPlusTitle")
te.putData("title","网页中的标题")
te.putData("bodyhtml","<script>alert('test');</script>")
te.putData("bodytext","普通的¥文本<br>$3331'")
te.putData("my",CreateMap("username":"icefairy","comefrom":"China"))
te.putData("footertext","关于我们(尾部)")
te.putData("logined",1)
te.putData("isadmin",0)
te.putData("onlyif",1)
te.putData("inta",3)
te.putData("stra","aaa")
te.putData("onlyiffalse",0)
'for循环演示(只支持map类型的list)这个list也可以是直接从数据库中查询出来的结果
Dim lst As List
lst.Initialize
For i=0 To 20
Dim m As Map
m.Initialize
m.Put("line1","text1:"&i)
m.Put("line2","text2:"&Rnd(0,100))
lst.Add(m)
Next
te.putData("testlist",lst)
te.renderTPL("/live/live")
End Sub
B4X:
support:
1.include:{# include "/header" #}
2.var:<div id='header'><h1>{# $title #}</h1></div>
3.map var:<p>我是:{# my.username #}</p> <p>我来自:{# my.comefrom #}</p>
4.if:<p>{# if isadmin #}是管理员{# else #} 不是管理员 {# endif #} </p>
5.for:<p>for循环演示
<table border="1">
<tr><td>第一行</td><td>第二行</td></tr>
{# for item in testlist #}
<tr><td>本行内容为:{# item.line1 #}</td>
<td>本行内容为:{# item.line2 #}</td></tr>
{# endfor #}
</table>
</p>
example:http://my.xlzbw.org:888/test
update:
2017-4-23 15:13:29
1.add initscanner auto scan all handler and add to server with actionkey defined in class_global sub
2.support:#MergeLibraries: false ,will copy depends library to objects\libs ,and will gen a bat file use to start the project(need java8 installed already);if you want regen the file just delete the bat file and run project from ide again;
3.add jarutils to support much function for class or jar like:GetAllClassesNames、GetAllClassesNamesFromJar、getClassProperties、getClassMethods、getClassByName、getpkgName、getSrcPath
4.add connectionstr demo and dbdriver
B4X:
'dbtype:0=mysql connstr:jdbc:mysql://127.0.0.1:3306/dbname?characterEncoding=UTF-8;autoReconnect=true;zeroDateTimeBehavior=convertToNull
'1=mssql connstr:jdbc:jtds:sqlserver://localhost:1433/dbname;instance=sqlexpress
'2=oracle connstr:jdbc:oracle:thin:@127.0.0.1:1521:orcl
Public Sub initConnectionPool(dbtype As Int,connectionStr As String,dbUser As String,dbPass As String)
curDbType=dbtype
Dim conCls As String=""
Select dbtype
Case 0
conCls="com.mysql.jdbc.Driver"
Case 1
conCls="net.sourceforge.jtds.jdbc.Driver"
Case 2
conCls="oracle.jdbc.driver.OracleDriver"
End Select
conpool.Initialize(conCls,connectionStr,dbUser,dbPass)
End Sub
Last edited: