简化版电子支付项目问题总结

1.spring3.2中 @component注解要引入spring-context-...jar包

 

2.由于在spring中配置事务,要用到org.apache.commons.dbcp.BasicDataSource这个类,因此你还要下载apache的commons-dbcp-1.4.jar 以及这个dbcp包依赖的commons-pool-1.6.jar包

 

3.hibernate4整合spring3.1的过程中,发现了java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider异常,查了一下相关资料,原来发现hibernate4已经将hibernate3的一些功能改掉了,在hibernate4已经不使用CacheProvider了,所以做了以下修改,

原先:<bean id="sessionFactory"

class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

改成:<bean id="sessionFactory"

class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

 

4.spring事务配置:

org.springframework.orm.hibernate4.HibernateTransactionManager,hibernate3要改成hibernate4

 

5.hibernate4不支持hibernateTemplate了,只用hibernate原生api操作持久化对象

 

6.hibernate3.5以后自带注解包

 

7.<constant name="struts.i18n.encoding" value="GBK" />只能解决通过post方式提交的乱码,get方式不行

 

8.在struts.xml中加入<constant name="struts.i18n.encoding" value="GB2312"></constant>后可以解决FORM表单中提交中文参数出现乱码的问题,但是不能解决URL传递中文参数(比如hello.action?msg=哈哈之类)出现乱码的问题

解决方法:

修改 tomcat/conf/server.xml

<Connector acceptCount='100' connectionTimeout='20000' debug='0'

      disableUploadTimeout='true' enableLookups='false'

      maxSpareThreads='75' maxThreads='150' minSpareThreads='25'

      port='8080' redirectPort='8443' URIEncoding='GBK'/>

加上 URIEncoding='GBK' 即可。

 

9.jsp中href不跳转(停在当前页面)不要用href="#",而用href="javascript:void(0)"

 

10.iterator 标签中的status属性代表当前迭代的位置; 

#of.last用于判断当前是否跌到的最后一个元素; 

last 返回一个boolean类型; 

first 返回一个boolean类型; 

当声明iterator的status属性时,通过#statusName.method 可以使用以下方法: 

even : boolean - 如果当前迭代位置是偶数返回true 

odd : boolean - 如果当前迭代位置是奇数返回true 

count : int - 返回当前迭代位置的计数(从1开始) 

index : int - 返回当前迭代位置的编号(从0开始) 

first : boolean - 如果当前迭代位置是第一位时返回true 

last : boolean - 如果当前迭代位置是最后一位时返回true 

modulus(operand : int) : int - 返回当前计数(从1开始)与指定操作数的模数

 

11.struts2随提供了循环控制标签<s:iterator/>,使用起来也比较方便,但在具体的应用中,也有不方便之处,他没有像struts1的<c:foreach/>标签,提供了begin、end等属性,支持自增变量的循环。遇到这种问题怎么解决?struts2提供了<s:bean/>标签,且提供了一个bean类:org.apache.struts2.util.Counter,该类中有first、last等属性,可用使用它获取自增值,如下:

<s:bean name="org.apache.struts2.util.Counter"id="counter">

<s:param name="first" value="1"/>

<s:param name="last" value="10"/>

<s:iterator>

<s:property/>

</s:iterator>

</s:bean>

其中first属性指定循环起始值,last指定循环终止值,其它相关属性可以查看org.apache.struts2.util.Counter类源码。在下面迭代器中输入循环的当前值,即:current-1

 

例1:分页中,select自增计数的控制

<select name="page"

οnchange="javascript:window.location='newslist.jsp?page='+this.value">

<s:beanname="org.apache.struts2.util.Counter">

<s:param name="first" value="1"/>

<s:param name="last" value="pageCount"/>

<s:iterator>

<option value="<s:property/>"

<s:iftest="%{page==(current-1)}">selected</s:if> >

<s:property />

</option>

</s:iterator>

</s:bean>

</select>

 

12.struts+spring的action测试

   加入struts2-junit-plugin-2.3.15.1.jar(没spring只需此包)

       spring-test-3.2.3.RELEASE.jar

   若有spring则继承StrutsSpringTestCase,单struts则继承StrutsTestCase

   测试例子:

      public class DownLoadActionTest extends StrutsSpringTestCase{

private ActionProxy proxy;

private DownLoadAction dla;

@Override  

    protected String[] getContextLocations() {

String arr[] ={"beans.xml"};

        return arr;    

    }  

 

private void init(){

request.setParameter("programId", "7");

        proxy=getActionProxy("downLoadReportFile");  

        dla=(DownLoadAction)proxy.getAction();  

    } 

@Test

public void testDownLoadReportFile() throws Exception{

init();

proxy.execute();

/*DownLoadAction downloadaction = new DownLoadAction();*/

dla.downLoadReportFile();

}

 

}

 

13.struts2 日期

  (1)、在jsp文件中加入<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>

  (2)、在head里加入<sx:head/>

  (3)、将<s:datetimepicker label="XXXX" name="XXXX"></s:datetimepicker>改为<sx:datetimepicker label="XXXX" name="XXXX"></sx:datetimepicker>

  (4)、将struts2-dojo-plugin-2.1.6.jar拷贝到/web-inf/lib下

   在ie浏览器下不能显示控件,firefox和chrome可以

 

14. 解决session超时跳转主页,跳出frameset

<script language="JavaScript">   

if (window != top)   

top.location.href = location.href;   

</script>

   

15.在hibernate中,设置fetchtype.EAGER要小心。设置成EAGER,则查询时是将多个表join的

 

16.用struts拦截器进行访问控制时,只能控制action的,不能限制用户直接输入jsp页面访问,拦截jsp方法有:

(1)可以通过自定义filter来控制,要把拦截的和不用拦截的(如登录界面)放在不同文件夹下

(2)可以把所有的jsp都放在WEB-INF下,此方法在tomcat服务器下可以用,在其他服务器(如weblogic)下不一定可行。

(3)写一个jsp页面判断,其他需要访问控制的<%@include file="" %> ,注意不能用<jsp:include>方法,此方法response.sendRedirect不管用

(4)acegi框架

 

17. struts2 json使用 

(1)jar包:commons-beanutils-1.7.0.jar

   commons-lang-2.1.jar

   commons-collections-3.1.jar

   ezmorph-1.0.3.jar

   json-lib-2.1.jar

   jsonplugin-0.33.jar

 (2) Bean------->JSONObject

           Map ------->JSONObject

           List------->JSONArray

(3)JSONObject.fromObject(list)后面的代码没执行

commons-lang3的包里没有了NestableRuntimeException这个类.

解决办法:只需把commons-lang的jar包换成2.6或之前的即可.

 

18. utf-8和gbk两种编码不要混用,easyui只能utf-8?中文包为UTF-8,可以将它转换成GBK

 

19.IE拒绝访问

<form method="post" name="fileform" id="fileform" enctype="multipart/form-data" action="uploadexamineFile?businessId=${b.businessID }&programId=${programId}&programName=${programName}">

    <input type="file" name="examineFile" id="examineFile${b.businessID }" 

       οnchange="this.form.submit();" style="display:none" class="required" accept="application/vnd.ms-excel,application/vnd.openxmlformats- officedocument.spreadsheetml.sheet,application/vnd.ms-excel.sheet.macroEnabled.12"/>

    <input id="uploadbutton${b.businessID}" type="submit" style="display:none" />

</form>

           

<a href='javascript:void(0);' οnclick="document.getElementById('examineFile${b.businessID}').click();return false;">[上传审核列表文件]</a></div></td>

 

οnchange="this.form.submit();"时IE拒绝访问,其他浏览器正常,此情况是IE出于安全考虑

解决方法:

http://jsfiddle.net/djibouti33/uP7A9/

        http://stackoverflow.com/questions/9396411/ie-javascript-form-submit-with-file-input

20.注意路径问题,设置basepath,IE和其他浏览器的相对路径不同

21.注意文件的组织,考虑权限控制

22.mysql在windos下数据库名和表名不区分大小写,在linux下区分大小写,设计的时候要注意

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值