struts 2 使用注意问题

来源:互联网 发布:开淘宝网店货源怎么找 编辑:程序博客网 时间:2024/04/30 11:51

 一、<s:if> 标签判断字符串相等

 

  错误写法:

 

  <s:if test="#user.userSex == 'M'">男 </s:if>

 

  正确写法:

 

  <s:if test='#user.userSex == "M"'>男 </s:if>

  <s:if test='%{#user.userSex == "M"}'>男 </s:if>

 

二、Struts2 textField标签的格式化

 

    1.在struts.properties中插入struts.custom.i18n.resources=globalMessages

    2.src目录建立globalMessages_zh_CN.properties,globalMessages_en_US.properties

       内容如下:

       global.datetime = {0, date, yyyy-MM-dd HH:mm:ss}

       global.date = {0, date, yyyy-MM-dd}

    3.页面调用部分:

    <s:textfield name="pi.applyDate"

     value="%{getText('global.date',{pi.applyDate})}"/>