代码改变世界

开发CRM中遇到的一些问题总结

2011-04-29 18:31  hanwesley  阅读(642)  评论(0编辑  收藏  举报

mvn jetty:run
rg.apache.jasper.JasperException: tag 'checkboxlist', field 'list', name 'selectRoleId': The requested list key 'roles' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]出现这个错误的原因可能如下:
1 刚进入该界面的时候发生错误,原因是 list="roles"中的这个集合是空的,导致错误
解决办法很简单,不能让list为空
2 刚进入该界面的时候list是有数据的,当点击提交等按钮的时候,数据被提交到后台,如果配置了验证框架或者在action中写了validate方法,校验没有通过,未走action,直接返回了input,又指定回了当前界面。此时的checkboxlist中的list丢失了,导致了如上错误(这个错误提示的不太友好,让人认为是类转换错误)
解决办法是把初始化list的工作放到prepare拦截器中,因为prepare是在validate拦截器之前执行,即实现prepareble接口:public class RoleAction extends ActionSupport implements Preparable{    @Override    public void prepare() throws Exception {        //初始化list    }}
<result-types>
            <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
            <result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
            <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
            <result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
            <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
            <result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
            <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>
            <result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>
            <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
            <result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />
            <!-- Deprecated name form scheduled for removal in Struts 2.1.0. The camelCase versions are preferred. See ww-1707 -->
            <result-type name="redirect-action" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
            <result-type name="plaintext" class="org.apache.struts2.dispatcher.PlainTextResult" />
        </result-types>                注意result类型 转发和重定向的区别                 <selectKey resultClass="java.lang.Long" type="pre" keyProperty="id" >            SELECT SEQ_CPS_TAOKE_GROUP_RELATION.nextval AS id from dual        </selectKey>         resultclass必须为long型,integer报错        com.ibatis.common.beans.ProbeException: Could not set property 'id' for com.taobao.ad.tu.dataobject.group.CpsGroupTaokeDO.  Cause: java.lang.IllegalArgumentException: argument type mismatch
function trim(str){    return str.replace(/(^\s*)|(\s*$)/g, "");  }
<s:if test="null==user||user.isEmpty()"> 集合为空 </s:if><s:else> 集合不为空 </s:else> or <s:if test="null!=user&&!user.isEmpty()"> 集合不为看空 </s:if> 

SELECT T.*,NUM FROM (select ROWNUM NUM, GROUP_ID,MEMBERID,STATUS,CREATE_TIME from CPS_GROUP_TAOKE_RELATION WHERE ROWNUM<5) T WHERE NUM>1 <span id="noGroup" style="display:none"><    <s:set name="url" value="'http://www.javaeye.com'"/>      <a href="<s:url value="%{#url}" />">javaeye</a>  

// 默认除法运算精度 private static final int DEFAULT_DIV_SCALE = 4;

realFee.divide(totalAlipayFee,DEFAULT_DIV_SCALE,BigDecimal.ROUND_HALF_EVEN);