??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲色图第一页,一个色综合网,√…a在线天堂一区http://www.aygfsteel.com/void241/category/48808.htmlzh-cnFri, 23 May 2014 22:06:24 GMTFri, 23 May 2014 22:06:24 GMT60freemarker如何取得目名称http://www.aygfsteel.com/void241/archive/2013/10/22/405489.htmlvoidvoidTue, 22 Oct 2013 02:40:00 GMThttp://www.aygfsteel.com/void241/archive/2013/10/22/405489.htmlhttp://www.aygfsteel.com/void241/comments/405489.htmlhttp://www.aygfsteel.com/void241/archive/2013/10/22/405489.html#Feedback0http://www.aygfsteel.com/void241/comments/commentRss/405489.htmlhttp://www.aygfsteel.com/void241/services/trackbacks/405489.html<#assign contextPath = request.contextPath/>  

void 2013-10-22 10:40 发表评论
]]>
struts2和freemarker集成实例 (注解方式)http://www.aygfsteel.com/void241/archive/2013/06/22/400847.htmlvoidvoidSat, 22 Jun 2013 02:22:00 GMThttp://www.aygfsteel.com/void241/archive/2013/06/22/400847.htmlhttp://www.aygfsteel.com/void241/comments/400847.htmlhttp://www.aygfsteel.com/void241/archive/2013/06/22/400847.html#Feedback0http://www.aygfsteel.com/void241/comments/commentRss/400847.htmlhttp://www.aygfsteel.com/void241/services/trackbacks/400847.html最q要开始做目了,目中可能会用到Struts2和Freemarker集成Q所以做了个实例l大家分享一下?/p>

 

        前期的配|web.xmlQ导入jar包就不给大家介绍了,q些内容做过struts2的朋友的非常熟?zhn)Q如果有不会的大家可以找一下帮助文档或者上互联|上搜烦一下解x法?/p>

 

        看过struts2l构囄朋友们都应该知道struts2的展现层不再是像struts1那样单纯的jsp了,它能够集成很多展现层技术,例如今天说的freemarker{等?/p>

 

 

 

        既然上面都说Cfreemarker仅仅是一个展现层技术,那么我们自然会想刎ͼfreemarker应该和struts2中配|的action标签中的result有关p,其实是q样的,我们知道struts2的result标签是匚w跌{路径控制展示层的作用Q所以我们利用struts2和freemarker的最q本操作是配置result标签Q把原先的result标签的type变成freemarkerQ蟩转的文g变成freemarker的模板文件即可。配|如下:

 

  1. <struts>   
  2.   
  3.  <package name="struts"extends="struts-default">   
  4.   
  5. <action name="userLogin"class="com.test.action.LoginAction" method="userLogin">   
  6.   
  7.        <result name="success" type="freemarker">   
  8.   
  9.          /WEB-INF/templates/user.ftl   
  10.   
  11.        </result>   
  12.   
  13.      </action>   
  14.   
  15.    </package>   
  16.   
  17. </struts>  


 

 

       如果我们要是用struts2的注解方式来配置a(chn)ction的话Q那么我们就会这样配|:

 

  1. @Action(value = "showadd"results ={ @Result(name = "success"type = "freemarker"location ="/flt/adduser.ftl") })  

 

 

 

        M是要改result的类型和跌{文gcd卛_?/p>

 

        最后我们说一下我们怎么模板中的变量变成实际的|q个也是比较单的Q我们这个工作要在action中实玎ͼ具体是我们要将模板中的变量定义到action中,q且生成get和setҎ(gu)Q最后在相应的业务方法中这个变量赋|q样struts2׃自动的ؓ我们值填写到模板中,形成真实的展现页面,最后蟩转显C给用户?/p>

 

       Freemarker的模板实例:

 

  1. <html>  
  2.   
  3. <head>  
  4.   
  5. <meta http-equiv="Content-Type" content="text/html;charset=gb2312">  
  6.   
  7. <title>Insert title here</title>  
  8.   
  9. </head>  
  10.   
  11. <body>  
  12.   
  13.        <formmethodformmethod="post" action="${formaction}" name="${formname}">  
  14.   
  15.                 
  16.   
  17.               <input id="${adduser_username}" name="${adduser_username}" type="${text}" value="" />  
  18.   
  19.               <input id="${adduser_password}" name="${adduser_password}" type="${text}" value=""/>  
  20.   
  21.               <input id="${adduser_submit}" name="${adduser_submit}" type="${submit}" value="adduser" />  
  22.   
  23.        </form>  
  24.   
  25. </body>  
  26.   
  27. </html>  

 

 

      对应的actionQ?/p>

 

  1. private Stringformaction;  
  2.   
  3.   
  4.   
  5. private Stringformname;  
  6.   
  7.   
  8.   
  9. private Stringadduser_username;  
  10.   
  11.   
  12.   
  13. private Stringadduser_password;  
  14.   
  15.   
  16.   
  17. private Stringadduser_submit;  
  18.   
  19.   
  20.   
  21. private Stringtext;  
  22.   
  23.   
  24.   
  25. private Stringsubmit;  
  26.   
  27.   
  28.   
  29. public StringgetAdduser_username() {  
  30.   
  31.        returnadduser_username;  
  32.   
  33. }  
  34.   
  35.   
  36.   
  37. publicvoidsetAdduser_username(String adduser_username) {  
  38.   
  39.        this.adduser_username = adduser_username;  
  40.   
  41. }  
  42.   
  43.   
  44.   
  45. public StringgetAdduser_password() {  
  46.   
  47.        returnadduser_password;  
  48.   
  49. }  
  50.   
  51.   
  52.   
  53. publicvoidsetAdduser_password(String adduser_password) {  
  54.   
  55.        this.adduser_password = adduser_password;  
  56.   
  57. }  
  58.   
  59.   
  60.   
  61. public StringgetAdduser_submit() {  
  62.   
  63.        returnadduser_submit;  
  64.   
  65. }  
  66.   
  67.   
  68.   
  69. publicvoid setAdduser_submit(Stringadduser_submit) {  
  70.   
  71.        this.adduser_submit = adduser_submit;  
  72.   
  73. }  
  74.   
  75.   
  76.   
  77. public StringgetText() {  
  78.   
  79.        returntext;  
  80.   
  81. }  
  82.   
  83.   
  84.   
  85. publicvoidsetText(String text) {  
  86.   
  87.        this.text =text;  
  88.   
  89. }  
  90.   
  91.   
  92.   
  93. public StringgetSubmit() {  
  94.   
  95.        returnsubmit;  
  96.   
  97. }  
  98.   
  99.   
  100.   
  101. publicvoidsetSubmit(String submit) {  
  102.   
  103.        this.submit =submit;  
  104.   
  105. }  
  106.   
  107.   
  108.   
  109. public StringgetFormaction() {  
  110.   
  111.        returnformaction;  
  112.   
  113. }  
  114.   
  115.   
  116.   
  117. publicvoidsetFormaction(String formaction) {  
  118.   
  119.        this.formaction =formaction;  
  120.   
  121. }  
  122.   
  123.   
  124.   
  125. public StringgetFormname() {  
  126.   
  127.        returnformname;  
  128.   
  129. }  
  130.   
  131.   
  132.   
  133. publicvoidsetFormname(String formname) {  
  134.   
  135.        this.formname =formname;  
  136.   
  137. }  
  138.   
  139.   
  140.   
  141.   
  142.   
  143. @Action(value= "showadd", results = { @Result(name ="success", type = "freemarker", location = "/flt/adduser.ftl") })  
  144.   
  145. public Stringshowadd() throws Exception {  
  146.   
  147.        /* 
  148.  
  149.         * FreeMarkerUtil freeMarkerUtil=newFreeMarkerUtil(); 
  150.  
  151.         * Map<String,Object> root=newHashMap<String,Object>(); //为数据模型添加?nbsp;
  152.  
  153.         * root.put("formaction","adduser"); root.put("formname", "adduser"); 
  154.  
  155.         *  
  156.  
  157.         * FileWriter out=new FileWriter(newFile("/adduser.ftl")); 
  158.  
  159.         * freeMarkerUtil.printFile("/flt","adduser.ftl",root, out); 
  160.  
  161.         */  
  162.   
  163.        setFormaction("adduser");  
  164.   
  165.        setFormname("adduser");  
  166.   
  167.        setAdduser_password("password");  
  168.   
  169.        setAdduser_submit("adduser_submit");  
  170.   
  171.        setAdduser_username("username");  
  172.   
  173.        setText("text");  
  174.   
  175.        setSubmit("submit");  
  176.   
  177.        return"success";  
  178.   
  179. }  

 

 

        q样我们q行p够看到我们的一个添加页面,需要填入用户名和密码?/p>

void 2013-06-22 10:22 发表评论
]]>
FreeMarker List Ҏ(gu)字段倒序输出http://www.aygfsteel.com/void241/archive/2011/12/14/366315.htmlvoidvoidWed, 14 Dec 2011 02:26:00 GMThttp://www.aygfsteel.com/void241/archive/2011/12/14/366315.htmlhttp://www.aygfsteel.com/void241/comments/366315.htmlhttp://www.aygfsteel.com/void241/archive/2011/12/14/366315.html#Feedback0http://www.aygfsteel.com/void241/comments/commentRss/366315.htmlhttp://www.aygfsteel.com/void241/services/trackbacks/366315.html<#list dataList as entityElement>
<#list dataList?reverse as entityElement>
<#list dataEntity?sort_by(["name"])?reverse as de>

void 2011-12-14 10:26 发表评论
]]>
FreeMarker 基础知识 表达?/title><link>http://www.aygfsteel.com/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.aygfsteel.com/void241/archive/2011/08/16/356652.html</guid><wfw:comment>http://www.aygfsteel.com/void241/comments/356652.html</wfw:comment><comments>http://www.aygfsteel.com/void241/archive/2011/08/16/356652.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/void241/comments/commentRss/356652.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/void241/services/trackbacks/356652.html</trackback:ping><description><![CDATA[<div><strong></strong><div>    表达式是FreeMarker的核心功能,FreeMarker中的插值支持多U表辑ּ?br /> <br /> <strong>一、直接指定?/strong></div> 直接指定值可以是字符丌Ӏ数倹{布?yu)倹{集合及Map对象?br /><br /> <strong>1. 字符?/strong><br /> 直接指定字符串g用单引号或双引号限定。字W串中可以用{义字W?#8221;\"。如果字W串内有大量的特D字W,则可以在引号的前面加上一个字母rQ则字符串内的所有字W都直接输出?br /> <br /> <strong>2. 数?/strong><br /> 数值可以直接输入,不需要引受FreeMarker不支持科学计数法?br /> <br /> <strong>3. 布尔?</strong><br /> 直接使用true或falseQ不使用引号?br /> <br /> <strong>4. 集合</strong><br /> 集合用中括号包括Q集合元素之间用逗号分隔?br /> 使用数字范围也可以表CZ个数字集合,?..5{同于集合[1, 2, 3, 4, 5]Q同样也可以?..1来表C[5, 4, 3, 2, 1]?br /> <br /> <strong>5. Map对象</strong><br /> Map对象使用花括号包括,Map中的key-value对之间用冒号分隔Q多lkey-value对之间用逗号分隔?br /> 注意QMap对象的key和value都是表达式,但key必须是字W串?br /> <br /> <strong>二、输出变量?/strong><br /> FreeMarker的表辑ּ输出变量Ӟq些变量可以是顶层变量,也可以是Map对象的变量,q可以是集合中的变量Qƈ可以使用点(.Q语法来讉KJava对象的属性?br /> <br /> <strong>1. 层变量</strong><br /> 所谓顶层变量就是直接放在数据模型中的倹{输出时直接?{variableName}卛_?br /> <br /> <strong>2. 输出集合元素</strong><br /> 可以Ҏ(gu)集合元素的烦引来输出集合元素Q烦引用中括号包括。如Q?输出[“1”Q?“2”Q? “3”]q个名ؓnumber的集合,可以?{number[0]}来输出第一个数字。FreeMarkerq支持用number[1..2]来表C原 集合的子集合[“2”Q?“3”]?br /> <br /> <strong>3. 输出Map元素</strong><br /> 对于JavaBean实例QFreeMarker一h它看作属性ؓkeyQ属性gؓvalue的Map对象?br /> 输出Map对象Ӟ可以使用点语法或中括可法,如下面的几种写法的效果是一LQ?br /> <span style="background-color: #cccccc;">             book.author.name                                                                                                                         </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">             book.author["name"]                                                                                                                      </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">             book["author"].name                                                                                                                      </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">             book["author"]["name"]                                                                                                                   </span><br /> 使用点语法时Q变量名字有和顶层变量一L限制Q但中括可法没有Q何限制?br /> <br /> <strong>三、字W串操作</strong><br /> <strong>1. 字符串连?/strong><br /> 字符串连接有两种语法Q?br /> Q?Q?使用${..}?{..}在字W串帔R内插入表辑ּ的|<br /> (2)  直接使用q接q算W?#8220;+”q接字符丌Ӏ?br /> 如,下面两种写法{效Q?br /> <span style="background-color: #cccccc;">              ${"Hello, ${user}"}                                                                                                                </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">              ${"Hello, " + user + "!"}                                                                                                         </span><br style="background-color: #cccccc;" /> 有一炚w要注意: ${..}只能用于文本部分作ؓ插D出,而不能用于比较等其他用途,如:<br /> <span style="background-color: #cccccc;">              <#if ${isBig}>Wow!</#if>                                                                                                                </span><br style="background-color: #cccccc;" /> <span style="background-color: #cccccc;">              </span><span style="background-color: #cccccc;"><#if "${isBig}">Wow!</#if></span><span style="background-color: #cccccc;">                                                                                                              </span><br /> 应该写成Q?br /> <span style="background-color: #cccccc;">              </span><span style="background-color: #cccccc;"><#if isBig>Wow!</#if></span><span style="background-color: #cccccc;">                                                                                                                     </span><br /> <br /> <strong>2. 截取子串</strong><br /> 截取子串可以Ҏ(gu)字符串的索引来进行,如果指定一个烦引|则取得字W串该烦引处的字W;如果指定两个索引|则截取两个烦引中间的字符串子丌Ӏ如Q?br /> <span style="background-color: #cccccc;">              </span><span style="background-color: #cccccc;"><#assign number="01234"></span><br /> <span style="background-color: #cccccc;">              </span><span style="background-color: #cccccc;">${number[0]} <#-- 输出字符0 --></span><br /> <span style="background-color: #cccccc;">              </span><span style="background-color: #cccccc;">${number[0..3]} <#-- 输出子串“0123” --></span><br /> <br /> <strong>四、集合连接操?br /> </strong>      q接集合的运符?#8220;+”<br /> <br /> <strong>五、Mapq接操作</strong><br /> Mapq接操作的运符?#8220;+”<br /> <br /> <strong>六、算术运符</strong><br /> FreeMarker表达式中支持“+”?#8220;Q?#8221;?#8220;*”?#8220;/”?#8220;%”q算W?br /> <br /> <strong>七、比较运符</strong><br /> 表达式中支持的比较运符有如下几U:<br /> 1. =Q或?=Q: 判断两个值是否相{;<br /> 2. !=Q?判断两个值是否不相等Q?br /> 注: =?=可以用作字符丌Ӏ数值和日期的比较,但两边的数据cd必须相同。而且FreeMarker的比较是_比较Q不会忽略大写及空根{?br /> 3. >Q或者gtQ: 大于<br /> 4. >=Q或者gteQ: 大于{于<br /> 5. <Q或者ltQ: 于<br /> 6. <=Q或者lteQ: 于{于<br /> 注: 上面q些比较q算W可以用于数字和日期Q但不能用于字符丌Ӏ大部分时候,使用gt?gt;有更好的效果Q因为FreeMarker会把>解释成标{l束字符。可以用括h避免q种情况Q如Q?lt;#if (x>y)>?br /> <br /> <strong>八、逻辑q算W?/strong><br /> 1. &&Q?逻辑与;<br /> 2. ||Q?逻辑或;<br /> 3. !Q?逻辑?br /> 逻辑q算W只能用于布?yu)倹{?br /> <br /> <strong>?ji)、内建函?/strong><br /> FreeMarker提供了一些内建函数来转换输出Q可以在M变量后紧?Q?后紧跟内建函敎ͼ可以通过内徏函数来{换输出变量?br /> <br /> 字符串相兛_用的内徏函数Q?br /> 1. htmlQ?对字W串q行HTML~码Q?br /> 2. cap_firstQ?使字W串W一个字母大写;<br /> 3. lower_caseQ?字W串转成写Q?br /> 4. upper_caseQ?字W串转成大写Q?br /> <br /> 集合相关常用的内建函敎ͼ<br /> 1. sizeQ?获得集合中元素的个数Q?br /> <br /> 数字值相兛_用的内徏函数Q?br /> 1. intQ?取得数字的整数部分?br /> <br /> <strong>十、空值处理运符</strong><br /> FreeMarker的变量必赋|否则׃抛出异常。而对于FreeMarker来说Qnull值和不存在的变量是完全一LQ因为FreeMarker无法理解null倹{?br /> FreeMarker提供两个q算W来避免I|<br /> 1. !Q?指定~失变量的默认|<br /> 2. ??Q判断变量是否存在?br /> !q算W有两种用法Qvariable!或variable!defaultValue。第一U用法不l变量指定默认|表明默认值是I字W串、长度ؓ0的集合、或长度?的Map对象?br /> 使用!q算W指定默认值ƈ不要求默认值的cd和变量类型相同?br /> ??q算W返回布?yu)|如:variable??Q如果变量存在,q回trueQ否则返回false?/div><img src ="http://www.aygfsteel.com/void241/aggbug/356652.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/void241/" target="_blank">void</a> 2011-08-16 19:13 <a href="http://www.aygfsteel.com/void241/archive/2011/08/16/356652.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Freemarker 取?Requesthttp://www.aygfsteel.com/void241/archive/2011/06/11/352078.htmlvoidvoidSat, 11 Jun 2011 01:45:00 GMThttp://www.aygfsteel.com/void241/archive/2011/06/11/352078.htmlhttp://www.aygfsteel.com/void241/comments/352078.htmlhttp://www.aygfsteel.com/void241/archive/2011/06/11/352078.html#Feedback0http://www.aygfsteel.com/void241/comments/commentRss/352078.htmlhttp://www.aygfsteel.com/void241/services/trackbacks/352078.html
Request

${RequestParameters['email']}
${RequestParameters.email}


void 2011-06-11 09:45 发表评论
]]>
վ֩ģ壺 | ǧ| | ʯ| | ԭƽ| ɽ| Ϫ| ʯ| | | | ˮ| ԭ| ϳ| Ӽ| | | Ρɽ| ͬ| ϳ| | | ƽ| | | | | | ɽ| Դ| ɽ| β| | | | ȫ| ¡| | ˫| |