是会话中止了吧
org.springframework.orm.hibernate3.SessionHolder改成org.springframework.orm.hibernate5.SessionHolder
把3改成5
1,先查看表的编码方式
show create table 表名;
2,查看列的编码方式,中文的编码应该为gbk或者是utf-8
ALTER TABLE `表名` CHANGE `列名` `列名` VARCHAR(45) CHARACTER SET UTF8 NOT NULL;
监听错误
解决了 原来我是前缀hibernate 没加。直接写了show_sql 这些。
原先有cfg.xml 是可以省略,这里不可以了。
java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
此问题以解决缺少aopalliance-1.0.jar
下载地址https://pan.baidu.com/s/1sjHOLIl
hibernate的xml文件里的方言配置的问题,添加上MySQL的版本号(我的是5)即可,
<!-- 指定Hibernate的连接方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
还有,检查一下你的MySQL的存储引擎是否是InnoDB,如不是请修改。
看你的mysql现在已提供什么存储引擎:
mysql> show engines;
1、MyISAM管理非事务表,提供高速存储和检索以及全文搜索能力,如果再应用中执行大量select操作,应该选择MyISAM
2、InnoDB用于事务处理,具有ACID事务支持等特性,如果在应用中执行大量insert和update操作,应该选择InnoDB
能加个联系方式发一下么 网盘下载文件有问题
貌似是没导包
有可能是Product类的属性名和jsp页面input的name属性不一致,最好把代码贴出来,这样才能确定原因
事务管理开了吗?
数据库编码改utf-8
可以修改mysql的配置文件 .ini,加
#服务端的编码方式
character-set-server=utf8
[client]
#客户端编码方式,最好和服务端保存一致
loose-default-character-set = utf8
返回“SUCCESS":表示进行业务处理成功时返回该字符串,同时也是execute()方法默认返回的字符串,如果不成功,则返回"ERROR"字符串,或者其他自定义字符串,这些字符串是用来在struts配置action时用到
action的method 对应了service的方法 还有form的action
application.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" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://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">
<bean id="usersAction" class="com.gcu.action.UsersAction" scope="prototype">
<property name="usersService" ref="usersService"></property>
</bean>
<bean id="usersService" class="com.gcu.service.UsersService" >
<property name="usersDao" ref="usersDao"></property>
</bean>
<bean id="usersDao" class="com.gcu.dao.UsersDao" >
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<context:property-placeholder location="classpath:jdbc.properties" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/gcu/entity/Users.hbm.xml</value>
</list>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
检查spring-tx-4.3.4.RELEASE.jar有没有导入
这个应该是你服务器启动的时候项目就报错了,所以从服务器里面找,,我秀逗了都没想到
可能你没导那个spring-tx的jar包
http://www.imooc.com/learn/679
乱码吧
知道了,这个模板方法要返回上面的对象,开始写的null
比如说你去存取钱同时另一人也在往里面打钱,事务要保证他们同时成功或者失败,执行前后保持数据一致,否则就会出现要么你取完钱,他同时也存完钱但是发现钱,但是他没有看到你取钱之后的数额而是原有数额,你也一样,数据就回出错。
spring未注入
求助大神们!
我默默地重启了一下编辑器,然后好了-。-
我也一样
1.看看 用户名/密码是否正确
2.数据库是否启动
3.看看spring的数据库、事务等配置文件
改一点内容
create database ssh character set utf8;
jdbc.url=jdbc:mysql://localhost:3306/ssh?characterEncoding=UTF-8
界面打不开 哈哈哈 404
你没获取到表单输入的值,所以为空