本人的资源,不要资源分。
http://download.csdn.net/source/470141
http://download.csdn.net/source/470141
解决方案 »
- 我是做java的想自学Android。
- 关于jsp页面点击一个超链接或按钮 弹出一个层得问题
- JDK
- 关于Spring 的applicationContext无法获得数据源的问题
- 为什么提示com.informix.jdbc.IfxDriver不存在?
- java调用一个WebService的短信接口,该如何实现发送短信功能呢?
- s2sh环境下使用注解开发的教学视频
- 小弟马上就要论文开题了,但是没有什么头绪,请各位前辈指点!
- 我们的系统需要使用EJB吗?
- EJB問題??????
- 关于Struts连接数据库Struts-config.xml的配置正确吗? 在Action那样读取连接可以吗?为什么会有问题呢? 新手上路,请多帮助!
- hibernate能mapping oracle10g中的long字段吗
以下是针对myeclipse的ide的1.先建立连接,开发阶段用的jdbc连接,开发完毕后,换成数据库连接池,使用c3p0,proxool,不要用dbcp了,hibernate3.0对它已经不是很兼容了。2.先添加hibernate包,不要hibernate自己生成的sessionFactory,在spring的applicationContext.xm中添加会更加方便,生成映射类,不需要它生成的dao,自己手动写database's crud 的dao接口。3.添加spring的包,不用在添加spring的时候生成sessionFactory,在applicationContext.xm中添加dataSource数据源,在添加sessionFactory,到此可以删除,你的Hibernate.cfg.xml了,然后就是编写你的业务层和服务层了,因为spring是依赖注射的,在dao的目录下编写对database的crud的接口,在dao.hibernate的目录下去实现在dao的目录的接口,在service目录中编写对database的crud的接口,在service.impl中编写在service目录的接口,服务层的类并不直接操作数据库,而是通过调用到层去操作,然后在applicationContext中添加bean的形式把你编写的接口和类添加进来。4,添加struts的包,在web层中去调用服务层操作数据库,在struts-config.xml中设置action类用spring来代理,这需要在struts-config.xml中添加插件,<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="ContextConfigLocation"
value="/WEB-INF/action-servlet.xml" />
</plug-in>并且将Action改为type="org.springframework.web.struts.DelegatingActionProxy",在WEB-INF下建立一个spring的配置文件:action-servlet.xml,它的遵循的是<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"></beans>如果用到struts的表单验证,还需在struts-config.xml文件里添加一个插件 <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/org/apache/struts/validator/validator-rules.xml,/WEB-INF/validations.xml" />
</plug-in>并且在WEB-INF下新建validations.xml文件格式如下:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd">
<form-validation> <global>
<constant>
<constant-name>phone</constant-name>
<constant-value>^\d{8}\d*$</constant-value>
</constant> </global>
<formset>
<form name="systemUserForm">
<field property="userName" depends="required">
<msg name="required"
key="systemUSer.addSystemUser.userName" />
</field>
<field property="userPwd" depends="required">
<msg name="required"
key="systemUSer.addSystemUser.userPwd" />
</field>
<field property="userPwdChk" depends="required">
<msg name="required"
key="systemUSer.addSystemUser.userPwdChk" />
</field>
<field property="userPhone"
depends="required,mask">
<msg name="required" key="systemUSer.addSystemUser.userPhone" />
<msg name="mask" key="errors.phone" />
<arg name="mask" key="systemUSer.addSystemUser.display.length" position="1"/>
<arg name="required" key="systemUSer.addSystemUser.display.userPhone" position="0"/>
<arg name="mask" key="systemUSer.addSystemUser.display.userPhone" position="0"/>
<var>
<var-name>mask</var-name>
<var-value>${phone}</var-value>
</var> </field>
<field property="userEmail" depends="required,email">
<msg name="required"
key="systemUSer.addSystemUser.userEmail" />
<msg name="email" key="errors.email"/>
<arg name="email" key="systemUSer.addSystemUser.display.userEmail" position="0"/>
</field>
</form>
<form name="loginForm">
<field property="userName" depends="required">
<msg name="required" key="systemUSer.login.userName" />
</field>
<field property="userPwd" depends="required">
<msg name="required" key="systemUSer.login.userPwd" />
</field> </form>
<form name="incomeExpTypeForm">
<field property="incExpTyp" depends="required">
<msg name="required"
key="systemUSer.incomeExpensesType.incExpTyp" />
</field> </form>
<form name="incomeExpensesForm">
<field property="incExpTypId" depends="required">
<msg name="required" key="IncomeExpenses.incExpTypId" />
</field>
<field property="incExpDesc" depends="required">
<msg name="required" key="IncomeExpenses.incExpDesc" />
</field> <field property="incExpMn" depends="required,double">
<msg name="required" key="IncomeExpenses.incExpMn" />
</field>
</form>
</formset></form-validation>好了整合完毕了,但是还有运行还有问题,因为还缺少一些包apache的commons-pool-1.3.jar,Spring 2.0 Web Libraries包,还有spring和Hibernate的asm包冲突,我的做法是删除Hibernate包中的asm.jar,asm-attrs.jar。5.在web.xml中添加spring自带的监听器,主要目的是让application知道spring的存在,格式如下:<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>如果项目大,表多的话,我建议spring的配置文件可以分为好几个,可以在dao层,service层,web层分开建立那样的话spring的配置文件会更加清晰,applicationContext_XXX.xml只要在web.xml中添加参数就可以了。6.在web.xml中添加spring自带的字符过滤器,省的自己再去写一个了,格式如下:<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter> <filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>