A new generation of Java template engines with high performance and scalability.
<!--jetbrick Template Engineer--><dependency> <groupId>com.github.subchen</groupId> <artifactId>jetbrick-template-springmvc</artifactId> <version>2.0.10</version ></dependency>
Http://git.oschina.net/sub/jetbrick-template/tree/master
Original: http://lafecat.iteye.com/blog/2042972
Jetbrick-template is a new generation of Java template engines with high performance and scalability. Suitable for dynamic HTML page output or code generation, alternative to templates such as JSP pages or Velocity. The instruction is similar to Velocity, and the expression is consistent with Java and easy to learn and use. At the end of this article, a simple SPRINGMVC integrated jetbrick.template template project is attached. 1. Configure Web. XML<?XML version= "1.0" encoding= "UTF-8"?> <Web-appxmlns= "Http://java.sun.com/xml/ns/javaee"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"version= "3.0"> <!--Load Jetbrick-template Configuration - <Context-param> <Param-name>Jetbrick-template-config-location</Param-name> <Param-value>/web-inf/jetbrick-template.properties</Param-value> </Context-param> <Listener> <Listener-class>Jetbrick.template.web.JetWebEngineLoader</Listener-class> </Listener> <!--Spring MVC Core Controller - <servlet> <Servlet-name>Mvc</Servlet-name> <Servlet-class>Org.springframework.web.servlet.DispatcherServlet</Servlet-class> <Init-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>Classpath:spring-mvc.xml</Param-value> </Init-param> <Load-on-startup>1</Load-on-startup> </servlet> <servlet-mapping> <Servlet-name>Mvc</Servlet-name> <Url-pattern>/*</Url-pattern> </servlet-mapping> <welcome-file-list> <Welcome-file>Index.html</Welcome-file> </welcome-file-list> </Web-app>Second, spring-mvc.xml configuration<Context:component-scanBase-package= "Jetbrick.template.samples.springmvc.controller"/> <Mvc:annotation-driven/> <Beanclass= "Jetbrick.template.web.springmvc.JetTemplateViewResolver"> < Propertyname= "suffix"value= ". Jetx" /> < Propertyname= "ContentType"value= "text/html; charset=utf-8" /> < Propertyname= "Order"value= "9999" /> </Bean>Third, jetbrick-template.properties configuration import.packages = Jetbrick.template.samples.dao, Jetbrick.template.samples.model Import.autoscan = True import.autoscan.packages = Jetbrick.template.samples Template.reloadable = True Compile.debug = True Input.encoding=utf-8 output.encoding=utf-8 template.path=/web-inf/jetx /Template.loader=jetbrick.template.resource.loader.filesystemresourceloader Template.suffix=.jetx IV, use<!DOCTYPE HTML> <HTML> <Head> <MetaCharSet= ' Utf-8 '> <Metahttp-equiv= "X-ua-compatible"content= "Ie=edge"> <title>Jetbrick-template samples</title> </Head> <Body>#define (UserInfo author)<Div>Welcome, ${author.name}!</Div> <BR/> <TableBorder= "1"width= "All"> <TR> <TD>Id</TD> <TD>Title</TD> <TD>Author</TD> <TD>Price</TD> <TD>Publication time</TD> </TR>#for (BookInfo book:author.getBooks ())<TR> <TD>${book.id}</TD> <TD>${book.name}</TD> <TD>${book.getauthoruser (). Name}</TD> <TD>${book.price.format ()}</TD> <TD>${book.publicationdate.format ("Yyyy-mm-dd")}</TD> </TR>#else<TR> <TDcolspan= "5"Height= "+">sorry! No data has been published yet!</TD> </TR>#end</Table> <BR/>Click here to return to the user list</br/>#include ("Includes/footer.jetx")</Body> </HTML>
Jetbrick, a new generation of Java template engines with high performance and scalability