笔记

链接数据库:
在myeclipse的window下的open perspection中点击 myeclipse database explorer创建DB browser链接数据库,添加jdbc。Myeclipse就会在applicationContext.xml中自动生成链接数据库的url等等。在url的<property>上方添加<property name="driverClassName" value="com.mysql.jdbc.Driver"/>创建连接词并赋值。
配置文件
Myeclipse会自动生成配置文件struts.xml与applicationContext.xml,在其中添加属性要谨慎,并且在<beans>中添加:xmlns:aop="http://www.springframework
org/schema/aop"xmlns:tx=" http://www.springframework.org/schema/tx"在<beans>中的xsi:schemaLocation=""中加入声明:http://www.springframework.org/ schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/
schema/tx/spring-tx-3.0.xsd">
创建数据库中的表
数据库中的表不用在数据库中创建,通过对实体类的注解和测试类便能顺利创建。

乱码问题

创建DB browser链接数据库的connection url数据库信息后加上:

?useUnicode=true&characterEncoding=UTF-8便能处理.乱码问题。

  applicationContext.xml中标签未声明

      检查<beans>中的xmlns:aop=””、xmlns:tx=””等等是否xsi:schemaLocation=""中声明;如果已经进行了声明,重启myeclipse便可以了。

界面跳转问题

检查Struts2中的class的名称是否在applicationContext.xml中的<bean>内如:

<bean id="student" class="com.action.StudentAction">

<property name="stuService" ref="stuService"></property>

</bean>

<bean id="stuService" class="com.service.impl.StudentServiceImpl">

<property name="stuDao" ref="stuDao"></property>

</bean>

<bean id="stuDao" class="com.dao.impl.StudentDaoImpl">

<property name="sessionFactory" ref="sessionFactory" />

如果具备的话,就是带码出现了错误。

posted on 2016-06-30 18:03  竹山新雨后  阅读(175)  评论(0编辑  收藏  举报

导航