﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-void-随笔分类-Freemarker</title><link>http://www.blogjava.net/void241/category/48808.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 23 May 2014 22:06:24 GMT</lastBuildDate><pubDate>Fri, 23 May 2014 22:06:24 GMT</pubDate><ttl>60</ttl><item><title>freemarker如何取得项目名称</title><link>http://www.blogjava.net/void241/archive/2013/10/22/405489.html</link><dc:creator>void</dc:creator><author>void</author><pubDate>Tue, 22 Oct 2013 02:40:00 GMT</pubDate><guid>http://www.blogjava.net/void241/archive/2013/10/22/405489.html</guid><wfw:comment>http://www.blogjava.net/void241/comments/405489.html</wfw:comment><comments>http://www.blogjava.net/void241/archive/2013/10/22/405489.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/void241/comments/commentRss/405489.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/void241/services/trackbacks/405489.html</trackback:ping><description><![CDATA[<span style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; font-size: 12px; line-height: 18px; background-color: #fafafa; ">&lt;#assign&nbsp;contextPath&nbsp;=&nbsp;request.contextPath/&gt; &nbsp;</span><img src ="http://www.blogjava.net/void241/aggbug/405489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/void241/" target="_blank">void</a> 2013-10-22 10:40 <a href="http://www.blogjava.net/void241/archive/2013/10/22/405489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>struts2和freemarker集成实例 (注解方式)</title><link>http://www.blogjava.net/void241/archive/2013/06/22/400847.html</link><dc:creator>void</dc:creator><author>void</author><pubDate>Sat, 22 Jun 2013 02:22:00 GMT</pubDate><guid>http://www.blogjava.net/void241/archive/2013/06/22/400847.html</guid><wfw:comment>http://www.blogjava.net/void241/comments/400847.html</wfw:comment><comments>http://www.blogjava.net/void241/archive/2013/06/22/400847.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/void241/comments/commentRss/400847.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/void241/services/trackbacks/400847.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">最近要开始做项目了，项目中可能会用到Struts2和Freemarker集成，所以做了个实例给大家分享一下。</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 前期的配置web.xml，导入jar包就不给大家介绍了，这些内容做过struts2的朋友的非常熟悉，如果有不会的大家可以找一下帮助文档或者上互联网上搜索一下解决方法。</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;看过struts2结构图的朋友们都应该知道struts2的展现层不再是像struts1那样单纯的jsp了，它能够集成很多展现层技术，例如今天说的freemarker等等。</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p align="center" style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; "><img src="http://img.my.csdn.net/uploads/201302/27/1361935934_6116.png" alt="" style="border: none; max-width: 100%; " /></p><div align="left" style="font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</div><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; "></p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;既然上面都说到了freemarker仅仅是一个展现层技术，那么我们自然会想到，freemarker应该和struts2中配置的action标签中的result有关系，其实就是这样的，我们知道struts2的result标签就是匹配跳转路径控制展示层的作用，所以我们利用struts2和freemarker的最近本操作就是配置result标签，把原先的result标签的type变成freemarker，跳转的文件变成freemarker的模板文件即可。配置如下：</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><div bg_java"="" style="width: 1119.6875px; line-height: 26px; "><div><div style="border-left-color: #999999; "><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="view plain">view plain</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="copy">copy</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="print">print</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="?">?</a><div style="position: absolute; left: 428px; top: 1198px; width: 29px; height: 14px; z-index: 99; "><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="29" height="14" name="ZeroClipboardMovie_1" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=29&amp;height=14" wmode="transparent"></div></div></div><ol start="1"><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&lt;struts&gt;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&lt;<span style="color: blue; ">package</span>&nbsp;name=<span style="color: red; ">"struts"</span><span style="color: blue; ">extends</span>=<span style="color: red; ">"struts-default"</span>&gt;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&lt;action&nbsp;name=<span style="color: red; ">"userLogin"</span><span style="color: blue; ">class</span>=<span style="color: red; ">"com.test.action.LoginAction"</span>&nbsp;method=<span style="color: red; ">"userLogin"</span>&gt;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;result&nbsp;name=<span style="color: red; ">"success"</span>&nbsp;type=<span style="color: red; ">"freemarker"</span>&gt;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/WEB-INF/templates/user.ftl&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/result&gt;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/action&gt;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&lt;/<span style="color: blue; ">package</span>&gt;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&lt;/struts&gt;&nbsp;&nbsp;</li></ol></div><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; "><br />&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如果我们要是用struts2的注解方式来配置action的话，那么我们就会这样配置：</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><div bg_html"="" style="width: 1119.6875px; line-height: 26px; "><div><div style="border-left-color: #999999; "><strong>[html]</strong>&nbsp;<a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="view plain">view plain</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="copy">copy</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="print">print</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="?">?</a><div style="position: absolute; left: 428px; top: 1699px; width: 29px; height: 14px; z-index: 99; "><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="29" height="14" name="ZeroClipboardMovie_2" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=29&amp;height=14" wmode="transparent"></div></div></div><ol start="1"><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">@Action(<span style="color: red; ">value</span>&nbsp;=&nbsp;<span style="color: blue; ">"showadd"</span>,&nbsp;<span style="color: red; ">results</span>&nbsp;={&nbsp;@Result(<span style="color: red; ">name</span>&nbsp;=&nbsp;<span style="color: blue; ">"success"</span>,&nbsp;<span style="color: red; ">type</span>&nbsp;=&nbsp;<span style="color: blue; ">"freemarker"</span>,&nbsp;<span style="color: red; ">location</span>&nbsp;=<span style="color: blue; ">"/flt/adduser.ftl"</span>)&nbsp;})&nbsp;&nbsp;</li></ol></div><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 总之就是要改result的类型和跳转文件类型即可。</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 最后我们说一下我们怎么将模板中的变量变成实际的值，这个也是比较简单的，我们这个工作要在action中实现，具体就是我们要将模板中的变量定义到action中，并且生成get和set方法，最后在相应的业务方法中将这个变量赋值，这样struts2就会自动的为我们将值填写到模板中，形成真实的展现页面，最后跳转显示给用户。</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Freemarker的模板实例：</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><div bg_html"="" style="width: 1119.6875px; line-height: 26px; "><div><div style="border-left-color: #999999; "><strong>[html]</strong>&nbsp;<a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="view plain">view plain</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="copy">copy</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="print">print</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="?">?</a><div style="position: absolute; left: 428px; top: 2042px; width: 29px; height: 14px; z-index: 99; "><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="29" height="14" name="ZeroClipboardMovie_3" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&amp;width=29&amp;height=14" wmode="transparent"></div></div></div><ol start="1"><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">html</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">head</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">meta</span>&nbsp;<span style="color: red; ">http-equiv</span>=<span style="color: blue; ">"Content-Type"</span>&nbsp;<span style="color: red; ">content</span>=<span style="color: blue; ">"text/html;charset=gb2312"</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">title</span><span style="color: blue; font-weight: bold; ">&gt;</span>Insert&nbsp;title&nbsp;here<span style="color: blue; font-weight: bold; ">&lt;/</span><span style="color: blue; font-weight: bold; ">title</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;/</span><span style="color: blue; font-weight: bold; ">head</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">body</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">formmethod</span><span style="color: red; ">formmethod</span>=<span style="color: blue; ">"post"</span>&nbsp;<span style="color: red; ">action</span>=<span style="color: blue; ">"${formaction}"</span>&nbsp;<span style="color: red; ">name</span>=<span style="color: blue; ">"${formname}"</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">input</span>&nbsp;<span style="color: red; ">id</span>=<span style="color: blue; ">"${adduser_username}"</span>&nbsp;<span style="color: red; ">name</span>=<span style="color: blue; ">"${adduser_username}"</span>&nbsp;<span style="color: red; ">type</span>=<span style="color: blue; ">"${text}"</span>&nbsp;<span style="color: red; ">value</span>=<span style="color: blue; ">""</span>&nbsp;<span style="color: blue; font-weight: bold; ">/&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">input</span>&nbsp;<span style="color: red; ">id</span>=<span style="color: blue; ">"${adduser_password}"</span>&nbsp;<span style="color: red; ">name</span>=<span style="color: blue; ">"${adduser_password}"</span>&nbsp;<span style="color: red; ">type</span>=<span style="color: blue; ">"${text}"</span>&nbsp;<span style="color: red; ">value</span>=<span style="color: blue; ">""</span><span style="color: blue; font-weight: bold; ">/&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; font-weight: bold; ">&lt;</span><span style="color: blue; font-weight: bold; ">input</span>&nbsp;<span style="color: red; ">id</span>=<span style="color: blue; ">"${adduser_submit}"</span>&nbsp;<span style="color: red; ">name</span>=<span style="color: blue; ">"${adduser_submit}"</span>&nbsp;<span style="color: red; ">type</span>=<span style="color: blue; ">"${submit}"</span>&nbsp;<span style="color: red; ">value</span>=<span style="color: blue; ">"adduser"</span>&nbsp;<span style="color: blue; font-weight: bold; ">/&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; font-weight: bold; ">&lt;/</span><span style="color: blue; font-weight: bold; ">form</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;/</span><span style="color: blue; font-weight: bold; ">body</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; font-weight: bold; ">&lt;/</span><span style="color: blue; font-weight: bold; ">html</span><span style="color: blue; font-weight: bold; ">&gt;</span>&nbsp;&nbsp;</li></ol></div><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 对应的action：</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><div bg_java"="" style="width: 1119.6875px; line-height: 26px; "><div><div style="border-left-color: #999999; "><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="view plain">view plain</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="copy">copy</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="print">print</a><a href="http://blog.csdn.net/lfsf802/article/details/8616924#" title="?">?</a><div style="position: absolute; left: 428px; top: 2697px; width: 29px; height: 14px; z-index: 99; "><embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="29" height="14" name="ZeroClipboardMovie_4" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&amp;width=29&amp;height=14" wmode="transparent"></div></div></div><ol start="1"><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">private</span>&nbsp;Stringformaction;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">private</span>&nbsp;Stringformname;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">private</span>&nbsp;Stringadduser_username;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">private</span>&nbsp;Stringadduser_password;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">private</span>&nbsp;Stringadduser_submit;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">private</span>&nbsp;Stringtext;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">private</span>&nbsp;Stringsubmit;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;StringgetAdduser_username()&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnadduser_username;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">publicvoidsetAdduser_username(String&nbsp;adduser_username)&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">this</span>.adduser_username&nbsp;=&nbsp;adduser_username;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;StringgetAdduser_password()&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnadduser_password;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">publicvoidsetAdduser_password(String&nbsp;adduser_password)&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">this</span>.adduser_password&nbsp;=&nbsp;adduser_password;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;StringgetAdduser_submit()&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnadduser_submit;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">publicvoid&nbsp;setAdduser_submit(Stringadduser_submit)&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">this</span>.adduser_submit&nbsp;=&nbsp;adduser_submit;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;StringgetText()&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returntext;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">publicvoidsetText(String&nbsp;text)&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">this</span>.text&nbsp;=text;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;StringgetSubmit()&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnsubmit;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">publicvoidsetSubmit(String&nbsp;submit)&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">this</span>.submit&nbsp;=submit;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;StringgetFormaction()&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnformaction;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">publicvoidsetFormaction(String&nbsp;formaction)&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">this</span>.formaction&nbsp;=formaction;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;StringgetFormname()&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;returnformname;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">publicvoidsetFormname(String&nbsp;formname)&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">this</span>.formname&nbsp;=formname;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: #646464; ">@Action</span>(value=&nbsp;<span style="color: red; ">"showadd"</span>,&nbsp;results&nbsp;=&nbsp;{&nbsp;<span style="color: #646464; ">@Result</span>(name&nbsp;=<span style="color: red; ">"success"</span>,&nbsp;type&nbsp;=&nbsp;<span style="color: red; ">"freemarker"</span>,&nbsp;location&nbsp;=&nbsp;<span style="color: red; ">"/flt/adduser.ftl"</span>)&nbsp;})&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; "><span style="color: blue; ">public</span>&nbsp;Stringshowadd()&nbsp;<span style="color: blue; ">throws</span>&nbsp;Exception&nbsp;{&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;FreeMarkerUtil&nbsp;freeMarkerUtil=newFreeMarkerUtil();&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Map&lt;String,Object&gt;&nbsp;root=newHashMap&lt;String,Object&gt;();&nbsp;//为数据模型添加值&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;root.put("formaction","adduser");&nbsp;root.put("formname",&nbsp;"adduser");&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;FileWriter&nbsp;out=new&nbsp;FileWriter(newFile("/adduser.ftl"));&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;freeMarkerUtil.printFile("/flt","adduser.ftl",root,&nbsp;out);&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setFormaction(<span style="color: red; ">"adduser"</span>);&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setFormname(<span style="color: red; ">"adduser"</span>);&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAdduser_password(<span style="color: red; ">"password"</span>);&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAdduser_submit(<span style="color: red; ">"adduser_submit"</span>);&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAdduser_username(<span style="color: red; ">"username"</span>);&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setText(<span style="color: red; ">"text"</span>);&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setSubmit(<span style="color: red; ">"submit"</span>);&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; ">return</span><span style="color: red; ">"success"</span>;&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; color: #555555; line-height: 18px; ">&nbsp;&nbsp;</li><li style="border-left-color: #999999; background-color: #f5fae2; line-height: 18px; ">}&nbsp;&nbsp;</li></ol></div><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Arial; line-height: 26px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这样我们运行就能够看到我们的一个添加页面，需要填入用户名和密码。</p><img src ="http://www.blogjava.net/void241/aggbug/400847.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/void241/" target="_blank">void</a> 2013-06-22 10:22 <a href="http://www.blogjava.net/void241/archive/2013/06/22/400847.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FreeMarker List 根据字段倒序输出</title><link>http://www.blogjava.net/void241/archive/2011/12/14/366315.html</link><dc:creator>void</dc:creator><author>void</author><pubDate>Wed, 14 Dec 2011 02:26:00 GMT</pubDate><guid>http://www.blogjava.net/void241/archive/2011/12/14/366315.html</guid><wfw:comment>http://www.blogjava.net/void241/comments/366315.html</wfw:comment><comments>http://www.blogjava.net/void241/archive/2011/12/14/366315.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/void241/comments/commentRss/366315.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/void241/services/trackbacks/366315.html</trackback:ping><description><![CDATA[<div>&lt;#list dataList as entityElement&gt;<br />&lt;#list dataList?reverse as entityElement&gt;<br />&lt;#list dataEntity?sort_by(["name"])?reverse as de&gt;</div><img src ="http://www.blogjava.net/void241/aggbug/366315.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/void241/" target="_blank">void</a> 2011-12-14 10:26 <a href="http://www.blogjava.net/void241/archive/2011/12/14/366315.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>FreeMarker 基础知识 表达式</title><link>http://www.blogjava.net/void241/archive/2011/08/16/356652.html</link><dc:creator>void</dc:creator><author>void</author><pubDate>Tue, 16 Aug 2011 11:13:00 GMT</pubDate><guid>http://www.blogjava.net/void241/archive/2011/08/16/356652.html</guid><wfw:comment>http://www.blogjava.net/void241/comments/356652.html</wfw:comment><comments>http://www.blogjava.net/void241/archive/2011/08/16/356652.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/void241/comments/commentRss/356652.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/void241/services/trackbacks/356652.html</trackback:ping><description><![CDATA[<div><strong></strong><div>&nbsp;&nbsp;&nbsp; 表达式是FreeMarker的核心功能，FreeMarker中的插值支持多种表达式。<br /> <br /> <strong>一、直接指定值</strong></div> 直接指定值可以是字符串、数值、布尔值、集合及Map对象。<br /><br /> <strong>1. 字符串</strong><br /> 直接指定字符串值使用单引号或双引号限定。字符串中可以使用转义字符&#8221;\"。如果字符串内有大量的特殊字符，则可以在引号的前面加上一个字母r，则字符串内的所有字符都将直接输出。<br /> <br /> <strong>2. 数值</strong><br /> 数值可以直接输入，不需要引号。FreeMarker不支持科学计数法。<br /> <br /> <strong>3. 布尔值 </strong><br /> 直接使用true或false，不使用引号。<br /> <br /> <strong>4. 集合</strong><br /> 集合用中括号包括，集合元素之间用逗号分隔。<br /> 使用数字范围也可以表示一个数字集合，如1..5等同于集合[1, 2, 3, 4, 5]；同样也可以用5..1来表示[5, 4, 3, 2, 1]。<br /> <br /> <strong>5. Map对象</strong><br /> Map对象使用花括号包括，Map中的key-value对之间用冒号分隔，多组key-value对之间用逗号分隔。<br /> 注意：Map对象的key和value都是表达式，但key必须是字符串。<br /> <br /> <strong>二、输出变量值</strong><br /> FreeMarker的表达式输出变量时，这些变量可以是顶层变量，也可以是Map对象的变量，还可以是集合中的变量，并可以使用点（.）语法来访问Java对象的属性。<br /> <br /> <strong>1. 顶层变量</strong><br /> 所谓顶层变量就是直接放在数据模型中的值。输出时直接用${variableName}即可。<br /> <br /> <strong>2. 输出集合元素</strong><br /> 可以根据集合元素的索引来输出集合元素，索引用中括号包括。如： 输出[&#8220;1&#8221;， &#8220;2&#8221;，  &#8220;3&#8221;]这个名为number的集合，可以用${number[0]}来输出第一个数字。FreeMarker还支持用number[1..2]来表示原 集合的子集合[&#8220;2&#8221;， &#8220;3&#8221;]。<br /> <br /> <strong>3. 输出Map元素</strong><br /> 对于JavaBean实例，FreeMarker一样把它看作属性为key，属性值为value的Map对象。<br /> 输出Map对象时，可以使用点语法或中括号语法，如下面的几种写法的效果是一样的：<br /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  book.author.name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  book.author["name"]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  book["author"].name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  book["author"]["name"]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span><br /> 使用点语法时，变量名字有和顶层变量一样的限制，但中括号语法没有任何限制。<br /> <br /> <strong>三、字符串操作</strong><br /> <strong>1. 字符串连接</strong><br /> 字符串连接有两种语法：<br /> （1） 使用${..}或#{..}在字符串常量内插入表达式的值；<br /> (2)&nbsp; 直接使用连接运算符&#8220;+&#8221;连接字符串。<br /> 如，下面两种写法等效：<br /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ${"Hello,  ${user}"}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  ${"Hello, " + user +  "!"}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </span><br style="background-color: #cccccc;" /> 有一点需要注意： ${..}只能用于文本部分作为插值输出，而不能用于比较等其他用途，如：<br /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &lt;#if ${isBig}&gt;Wow!&lt;/#if&gt;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background-color: #cccccc;">&lt;#if  "${isBig}"&gt;Wow!&lt;/#if&gt;</span><span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   </span><br /> 应该写成：<br /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background-color: #cccccc;">&lt;#if isBig&gt;Wow!&lt;/#if&gt;</span><span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   </span><br /> <br /> <strong>2. 截取子串</strong><br /> 截取子串可以根据字符串的索引来进行，如果指定一个索引值，则取得字符串该索引处的字符；如果指定两个索引值，则截取两个索引中间的字符串子串。如：<br /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background-color: #cccccc;">&lt;#assign number="01234"&gt;</span><br /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="background-color: #cccccc;">${number[0]} &lt;#-- 输出字符0 --&gt;</span><br /> <span style="background-color: #cccccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="background-color: #cccccc;">${number[0..3]} &lt;#--  输出子串&#8220;0123&#8221; --&gt;</span><br /> <br /> <strong>四、集合连接操作<br /> </strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 连接集合的运算符为&#8220;+&#8221;<br /> <br /> <strong>五、Map连接操作</strong><br /> Map连接操作的运算符为&#8220;+&#8221;<br /> <br /> <strong>六、算术运算符</strong><br /> FreeMarker表达式中支持&#8220;+&#8221;、&#8220;－&#8221;、&#8220;*&#8221;、&#8220;/&#8221;、&#8220;%&#8221;运算符。<br /> <br /> <strong>七、比较运算符</strong><br /> 表达式中支持的比较运算符有如下几种：<br /> 1. =（或者==）： 判断两个值是否相等；<br /> 2. !=： 判断两个值是否不相等；<br /> 注： =和!=可以用作字符串、数值和日期的比较，但两边的数据类型必须相同。而且FreeMarker的比较是精确比较，不会忽略大小写及空格。<br /> 3. &gt;（或者gt）： 大于<br /> 4. &gt;=（或者gte）： 大于等于<br /> 5. &lt;（或者lt）： 小于<br /> 6. &lt;=（或者lte）： 小于等于<br /> 注： 上面这些比较运算符可以用于数字和日期，但不能用于字符串。大部分时候，使用gt比&gt;有更好的效果，因为FreeMarker会把&gt;解释成标签的结束字符。可以使用括号来避免这种情况，如：&lt;#if (x&gt;y)&gt;。<br /> <br /> <strong>八、逻辑运算符</strong><br /> 1. &amp;&amp;： 逻辑与；<br /> 2. ||： 逻辑或；<br /> 3. !： 逻辑非<br /> 逻辑运算符只能用于布尔值。<br /> <br /> <strong>九、内建函数</strong><br /> FreeMarker提供了一些内建函数来转换输出，可以在任何变量后紧跟?，?后紧跟内建函数，就可以通过内建函数来转换输出变量。<br /> <br /> 字符串相关常用的内建函数：<br /> 1. html： 对字符串进行HTML编码；<br /> 2. cap_first： 使字符串第一个字母大写；<br /> 3. lower_case： 将字符串转成小写；<br /> 4. upper_case： 将字符串转成大写；<br /> <br /> 集合相关常用的内建函数：<br /> 1. size： 获得集合中元素的个数；<br /> <br /> 数字值相关常用的内建函数：<br /> 1. int： 取得数字的整数部分。<br /> <br /> <strong>十、空值处理运算符</strong><br /> FreeMarker的变量必须赋值，否则就会抛出异常。而对于FreeMarker来说，null值和不存在的变量是完全一样的，因为FreeMarker无法理解null值。<br /> FreeMarker提供两个运算符来避免空值：<br /> 1. !： 指定缺失变量的默认值；<br /> 2. ??：判断变量是否存在。<br /> !运算符有两种用法：variable!或variable!defaultValue。第一种用法不给变量指定默认值，表明默认值是空字符串、长度为0的集合、或长度为0的Map对象。<br /> 使用!运算符指定默认值并不要求默认值的类型和变量类型相同。<br /> ??运算符返回布尔值，如：variable??，如果变量存在，返回true，否则返回false。</div><img src ="http://www.blogjava.net/void241/aggbug/356652.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/void241/" target="_blank">void</a> 2011-08-16 19:13 <a href="http://www.blogjava.net/void241/archive/2011/08/16/356652.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Freemarker 取值 Request</title><link>http://www.blogjava.net/void241/archive/2011/06/11/352078.html</link><dc:creator>void</dc:creator><author>void</author><pubDate>Sat, 11 Jun 2011 01:45:00 GMT</pubDate><guid>http://www.blogjava.net/void241/archive/2011/06/11/352078.html</guid><wfw:comment>http://www.blogjava.net/void241/comments/352078.html</wfw:comment><comments>http://www.blogjava.net/void241/archive/2011/06/11/352078.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/void241/comments/commentRss/352078.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/void241/services/trackbacks/352078.html</trackback:ping><description><![CDATA[<br /><div><span style="color: #000000; font-size: 18pt;">Request</span></div><br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #000000; ">${RequestParameters['email']}<br />${RequestParameters.email}</span></div><img src ="http://www.blogjava.net/void241/aggbug/352078.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/void241/" target="_blank">void</a> 2011-06-11 09:45 <a href="http://www.blogjava.net/void241/archive/2011/06/11/352078.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>