关于S2SH整合的问题

在我提交jsp网页的时候出现了下面的错误。

javax.servlet.ServletException: java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

root cause

1个回答

[quote]attempt to create saveOrUpdate event with null entity[/quote]

要存储或更新的实体对象为null

即是你的 save(XXEntity) 传入的是null

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
s2sh整合开发的问题异常捕捉问题
在开发当中我应该尽量在那一层去catch异常啊,在网上查过很多信息都意见不一,希望大神能帮我解答下,分数不高,请各位见谅
【求助】关于S2SH整合遇到的Error creating bean with name 'sessionFactory'
这是生成的applicationContext.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306//ideal-workshop"></property> <property name="username" value="root"></property> <property name="password" value="mysql"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> </bean> </beans> import java.sql.Connection; import java.sql.SQLException; import org.apache.commons.dbcp.BasicDataSource; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Test { public static void main(String[] args) throws SQLException { ApplicationContext ap=new ClassPathXmlApplicationContext("applicationContext.xml"); // BasicDataSource dataSource=(BasicDataSource) ap.getBean("dataSource"); // Connection con=(Connection) dataSource.getConnection(); // System.out.println(con); SessionFactory sf=(SessionFactory) ap.getBean("sessionFactory"); Session session = sf.openSession(); Transaction trans=session.beginTransaction(); trans.begin(); session.createSQLQuery("create table users").executeUpdate(); trans.commit(); } } 这是我Test类,主要是通过ApplicationContext ap得到dataSource或者sessionFactory实例来测试数据库是否连接正常,但是却爆出无法create bean异常: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Error applying BeanValidation relational constraints at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.idealworkshop.test.Test.main(Test.java:20) Caused by: org.hibernate.HibernateException: Error applying BeanValidation relational constraints at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.applyRelationalConstraints(BeanValidationIntegrator.java:219) at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:126) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1744) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1782) at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:189) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:350) at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:335) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452) ... 12 more
s2sh框架问题,用注解多还是xML
s2sh框架整合的时候,用xml多还是注解多,感觉注解的速度有点慢,但是可以省写很多代码。
求问s2sh整合时候需要哪些包
网上搜到的包大部分都是用的spring.jar这个整合包,而且hibernate版本都是3,每次导包都会少一些包,有没有哪位知道spring3,struts2,hibernate4整合时候需要那些包啊?最好能把所使用的框架的版本也说明下,也可以把某个项目所导入的包的图截一下,新手求教,感激不尽。
S2SH整合后发送邮件!!!!!!!!!!!!!
单独的用Struts2和javamail去发送邮件能够成功,但是在S2SH里面,服务器部署之后连网页都打不开,然后把发送邮件部分去掉,网页又能打开,希望遇到这个问题或者有经验的哥哥姐姐教教我,我真的花了很多时间还是不知道怎么去解决!!谢谢各位了!!!
S2SH整合,hibernate5配置了hibernateOpenSessionInViewFilter还是出现nosession
用到多表查询的时候,会出现该错误,详细如下![图片说明](https://img-ask.csdn.net/upload/202002/27/1582799256_153583.png)![图片说明](https://img-ask.csdn.net/upload/202002/27/1582799263_128377.png)
S2SH整合NullPointerException
[color=darkred]异常信息如下:[/color] description The server encountered an internal error () that prevented it from fulfilling this request. exception java.lang.NullPointerException com.axisoft.applicationExercise.action.testAction.testMethod(testAction.java:25) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452) com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254) com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166) com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248) org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) [color=darkred]Web.XML信息如下:[/color] <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext*.xml</param-value> </context-param> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <session-config> <session-timeout>30</session-timeout> </session-config> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> [color=darkred]applicationContext.xml信息如下:[/color] <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@xxx.xxx.x.xxx:1521:PEGA"/>(IP用"x"代替) <property name="username" value="RAIN"/> <property name="password" value="RAIN"/> </bean> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.jdbc.fetch_size">50</prop> <prop key="hibernate.jdbc.batch_size">50</prop> </props> </property> </bean> <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- Transaction manager for a single Jdbc DataSource --> <bean id="jdbcTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate"> <property name="transactionManager" ref="transactionManager" /> </bean> <!-- Jdbc template for a single Jdbc DataSource --> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="testService" class="com.axisoft.applicationExercise.createApplication.service.TestService" /> [color=darkred]Action信息如下:[/color] private ITestService testService; public String testMethod() { /*if (null == testService) { System.out.println("果为空"); return SUCCESS; }*/ String helloStr = testService.testMethod(); System.out.println("helloStr : " + helloStr); System.out.println("测试成功 : " + helloStr); return SUCCESS; } public ITestService getTestService() { return testService; } public void setTestService(ITestService testService) { this.testService = testService; } [color=darkred]Service信息如下:[/color] @Override public String testMethod() { // testDao.testMethod(); return "Hello"; } [color=darkred]JSP页面信息如下[/color] <a href="testSS.action">&lt;click me&gt;</a> <form action="testSS.action"> <input type="submit" value="ddd"/> </form> 哪位请指点一下,错误在哪,当我点击链接或者按钮的时候为什么会出现NullPointerException,谢谢了
请教S2SH整合,hibernate的多对多关系!联合主键查询问题!求指教!!!!!!!!!
goods商品表 int goodsid 自增,主键 varchar goodsName varchar goodsAdress relation中间表 int goods_id 主键 (无自增) 是goods表的外键 int stor_id 主键(无自增)是stor表的外键 int goodsNum int price stor 仓库表 int stor_id 主键,自增 varchar storName varchar storAdress S2SH整合 这3个Pojo类和hibernate.hbm.xml是逆向自动生成的。 怎么查询出3个表中所有的数据同时传递到JSP页面。越详细越好!注重方法! 谢谢。。求指教 !!
s2sh框架整合,hibernate无法执行删除问题
dao层的代码 public void deleteDepartment(Serializable id,String delMode) { Department department=this.getDepartmentById(id); //通过页面出来的参书id,获得 这个对象 if("del_pre_relation".equals(delMode)){ Set<User> users = department.getUsers(); for(User user:users){ user.setDepartment(null); } } this.getHibernateTemplate().delete(department); } action层的代码 public String deleteDepartment(){ this.departmentService.deleteDepartment(this.getModel().getDid(), "del"); return "action2action"; } SessionFactory 的配置方式 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation"> <value>classpath:hibernate/hibernate.cfg.xml</value> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory"></ref> </property> </bean> <tx:advice id="tx" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" read-only="false"/> <tx:method name="delete" read-only="false" /> <tx:method name="update*" read-only="false"/> <tx:method name="get*" read-only="true"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution(* cn.service.impl.*.*(..))" id="perform"/> <aop:advisor advice-ref="tx" pointcut-ref="perform"/> </aop:config> </beans> hibernate.cfg.xml <session-factory> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">1111</property> <property name="jdbc.fetch_size">50</property> <!-- 配置C3p0连接池 --> <!-- 启用c3p0连接池 设置连接池提供的供应商 --> <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> <!-- 最大连接数 --> <property name="c3p0.max_size">20</property> <!-- 最小连接数 --> <property name="c3p0.min_size">5</property> <!-- 每次请求连接的数目 --> <property name="c3p0.acquire_increment">5</property> <!-- 设置过期时间,以秒为单位,如果连接池中 -处于空闲状态的连接超过了这个时间,该连接就会从连接池中删除--> <property name="c3p0.timeout">120</property> <!-- 每个3000秒检查连接池中的空闲连接 --> <property name="c3p0.idle_test_period">3000</property> <!-- 设置隔离级别 1 2 4 8--> <property name="connection.isolation">2</property> <!-- 配置session的线程本地化 threadLocal --> <property name="current_session_context_class">thread</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> <property name="hibernate.hbm2ddl.auto">update</property> <property name="hibernate.show_sql">true</property> <mapping resource="cn/domain/hibernate-user.xml"/> <mapping resource="cn/domain/hibernate-department.xml"/> <mapping resource="cn/domain/hibernate-post.xml"/> </session-factory> </hibernate-configuration> 可是就是执行不了,debug了Dao层的delete方法,也都是执行了的,求教大神是怎么回事
s2sh整合做登录模块出现的问题,莫名奇妙
刚用s2sh整合做项目(只做了登录模块),都配置好了,可以连接数据库,第一次连接数据库获取数据等操作都可以,但是页面刷新几次之后就连接不上了,页面无法跳转,一直显示正在连接。设了断点,发现可以请求到action,但是一用hibernate向数据库取数据时,就断开了,也没有报错(好像是hibernate取数据卡在那边了,没有打印出hibernate的sql) 为什么会有这种情况呢?前几次请求hibernate取数据都可以,刷新多次后就不行了,纳闷呀。 我没有用连接池等。 spring配置如下: <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"> </property> <property name="url" value="jdbc:sqlserver://localhost:1433;databaseName=bearBook"> </property> <property name="username" value="sa"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <bean id="SystemUserDAO" class="com.bear.dao.impl.SystemUserDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="SystemUserService" class="com.bear.service.impl.SystemUserService"> <property name="systemUserDAO" ref="SystemUserDAO"></property> </bean> <bean id="systemUser" class="com.bear.view.SystemUserAction"> <property name="systemUserService" ref="SystemUserService"></property> </bean> struts配置文件如下: <struts> <constant name="struts.devMode" value="true"></constant> <package name="houtai" extends="struts-default"> <action name="systemUser" class="systemUser" > <result name="index" >/background/index.jsp</result> <result name="error">/background/login.jsp?error=1</result> </action> </package> </struts> hibernate配置如下: <hibernate-configuration> <session-factory> <property name="show_sql">true</property> <property name="dialect"> org.hibernate.dialect.SQLServerDialect </property> <mapping resource="com/bear/dao/pojo/BookInfo.hbm.xml" /> <mapping resource="com/bear/dao/pojo/BookType.hbm.xml" /> <mapping resource="com/bear/dao/pojo/SystemUser.hbm.xml" /> </session-factory> </hibernate-configuration> SystemUserAction中的方法: public String check(){ systemUser = systemUserService.checkUser(userName, password); if(systemUser==null){ return "error"; }else{ HttpSession session = ServletActionContext.getRequest().getSession(); session.setAttribute("systemUser", systemUser); return "index"; } } 调用的SystemUserService中的方法: public SystemUser checkUser(String userName, String password) { String hql = "from SystemUser where userName=? and password=?"; Object[]values={userName,password}; List<SystemUser> list = systemUserDAO.query(hql,values); SystemUser systemUser = null; if(list.size()!=0){ systemUser = list.get(0); } return systemUser; } 调用的SystemUserDAO中的方法: public List query(String hql,Object...values) { Query query = getSession().createQuery(hql); for(int i=0;i<values.length;i++){ //相当于rs.setObject query.setParameter(i, values[i]); } return query.list(); } 为什么头几次登录都可以(hibernate可以打印出sql语句),多请求几次,hibernate那端就卡在那边了,没有打印出sql语句,页面一直是正在连接。。。连接不上~ spring注入都可以
关于S2SH3大框架整合后,hibernate无异常提醒问题。
调用查询数据库操作的时候,HQL语句写错也没有错误提示。其中我的代码封装如下: hibernate、struts2配置已经整合到spring中。 1. 处理页面传来的值的 action类: public class ManagerAction extends BaseAction{ @Resource private ManagerInter managerImpl; private Manager manager; public String recManager(){ String account = manager.getAccount(); String paswd = manager.getPassword(); System.out.println(account+" "+paswd); List<Manager> managers = managerImpl.executeQuery("from Manager",account,paswd); return "success"; } public Manager getManager() { return manager; } public void setManager(Manager manager) { this.manager = manager; } public void setManagerImpl(ManagerInter managerImpl) { this.managerImpl = managerImpl; } 这段代码中的HQL语句是明显错误,但却没有异常抛出。在HQL语句正确的情况下,是能正常的查询出数据,故已经排除数据库异常,代码错误,没织入spring容器等错误。 2. 这个查询方法是调用了 ManagerInter 接口里的方法,已经织入spring,其中ManagerInter接口代码如下: public interface ManagerInter extends BaseDaoInter{ //这个接口写入该业务专有方法 } 这个接口是继承了一个基础接口,基础接口代码如下: public interface BaseDaoInter { /** * 查询方法 * */ public List executeQuery(String hql , Object...prameters); } 其中实现类如下: @Transactional public abstract class BaseDaoImpl implements BaseDaoInter{ @Resource private SessionFactory sessionFactory; //查询方法 public List executeQuery(String hql, Object... prameters) { Query query = sessionFactory.getCurrentSession().createQuery(hql); if(prameters!=null&&prameters.length>0){ for (int i = 0; i < prameters.length; i++) { query.setParameter(i, prameters[i]); } } return query.list(); } } 问:要怎样做才能让错误抛出。 我已经尝试过的方法: public List executeQuery(String hql, Object... prameters) { Query query = null; try { query = sessionFactory.getCurrentSession().createQuery(hql); if (prameters != null && prameters.length > 0) { for (int i = 0; i < prameters.length; i++) { query.setParameter(i, prameters[i]); } } } catch (Exception e) { throw new RuntimeException(e.getMessage()); } return query.list(); } 对这个实现类 进行 异常扑捉,可是不行。 问:怎么办?
S2SH整合出现的三大问题,希望大家一起解决,谢谢。
差不多没分了,但还是希望好心人能帮俺解决。 [size=x-large]问题1:[/size] 我的applicationContext.xml放在WEB-INF目录下,在web.xml应该怎样配置,如果放在src目录下又怎样配置?但我无论放在哪里都没能以set方法成功注入,只能通过new FileSystemXmlApplicationContext或new ClassPathXmlApplicationContext("applicationContext.xml")来getBean获取。 我在web.xml里配置: <context-param> <param-name>contextConfigLocation </param-name> <!--三种都不行--> <!-- <param-value>/WEB-INF/classes/applicationContext.xml </param-value> --> <!-- <param-value>WEB-INF/:applicationContext.xml, </param-value> --> <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/applicationContext_*.xml</param-value> </context-param> [size=x-large]问题2:[/size] SSH整合时,连接过多会显示too many Connection,用jdbc时出现这个问题是,可以用ptmt.close()、con.close()就可以解决,但用SSH时怎样关掉连接呢?用Spring配置还是在连接里面用session.close()? 问题3: java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException 我用的是MyEclipse8.6和Tomcat6.0 我已经导入了很多库,其中Struts 2 Spring Libraries中的spring-beans-2.5.6.jar和Spring 3.0 Core Libraries中的org.springframework.core-3.0.1.RELEASE-A.jar都有 org.springframework.beans.FatalBeanException,而且部署以后Tomcat6.0的wabapps目录lib下也有相应的spring-beans-2.5.6.jar包和org.springframework.core-3.0.1.RELEASE-A.jar,但是还是报错: [code="java"] 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:892) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 2011-1-3 13:05:57 org.apache.catalina.core.StandardContext start 严重: Error listenerStart 2011-1-3 13:05:57 org.apache.catalina.core.StandardContext start 严重: Context [/UserServiceManage] startup failed due to previous errors 2011-1-3 13:05:58 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository. 2011-1-3 13:05:59 org.apache.coyote.http11.Http11AprProtocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2011-1-3 13:05:59 org.apache.coyote.ajp.AjpAprProtocol start 信息: Starting Coyote AJP/1.3 on ajp-8009 2011-1-3 13:05:59 org.apache.catalina.startup.Catalina start 信息: Server startup in 27801 ms [/code]
S2SH整合时报错多谢各位
<p>hibernate配置文件</p> <pre name="code" class="xml">&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt; &lt;!-- Generated by MyEclipse Hibernate Tools. --&gt; &lt;hibernate-configuration&gt; &lt;session-factory&gt; &lt;property name="dialect"&gt; org.hibernate.dialect.MySQLDialect &lt;/property&gt; &lt;property name="connection.url"&gt; jdbc:mysql://localhost:3306/mydb &lt;/property&gt; &lt;property name="connection.username"&gt;root&lt;/property&gt; &lt;property name="connection.password"&gt;a&lt;/property&gt; &lt;property name="connection.driver_class"&gt; com.mysql.jdbc.Driver &lt;/property&gt; &lt;property name="myeclipse.connection.profile"&gt;mysql&lt;/property&gt; &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt; &lt;mapping resource="com/james/domain/User.hbm.xml" /&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt;</pre> <p> </p> <p>spring配置文件</p> <p> </p> <p> </p> <pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"&gt; &lt;context:annotation-config/&gt; &lt;context:component-scan base-package="com.james"/&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt; &lt;property name="configLocation" value="classpath:hibernate.cfg.xml"&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt; &lt;/bean&gt; &lt;bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"&gt; &lt;property name="sessionFactory" ref="hibernateTemplate"/&gt; &lt;/bean&gt; &lt;tx:annotation-driven transaction-manager="txManager"/&gt; &lt;/beans&gt;</pre> <p> userdaoImpl内容为</p> <p> </p> <p> </p> <p> </p> <pre name="code" class="java">package com.james.dao.impl; import java.util.List; import javax.annotation.Resource; import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.stereotype.Component; import com.james.dao.UserDao; import com.james.domain.User; @Component public class UserDaoImpl implements UserDao { HibernateTemplate hibernateTemplate; public boolean del(int id) { // TODO Auto-generated method stub return false; } public List&lt;User&gt; findAll() { // TODO Auto-generated method stub return null; } public User findById(int id) { // TODO Auto-generated method stub return null; } public List&lt;User&gt; findByName(String userName) { // TODO Auto-generated method stub return null; } public boolean save(User user) { System.out.println("running here userdao save"); hibernateTemplate.save(user); // TODO Auto-generated method stub return false; } public boolean update(User user) { // TODO Auto-generated method stub return false; } public HibernateTemplate getHibernateTemplate() { return hibernateTemplate; } @Resource public void setHibernateTemplate(HibernateTemplate hibernateTemplate) { this.hibernateTemplate = hibernateTemplate; } } </pre> <p> </p> <p>报错内容为</p> <p> </p> <pre name="code" class="java">Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.orm.hibernate3.HibernateTemplate] to required type [org.hibernate.SessionFactory] for property 'sessionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.orm.hibernate3.HibernateTemplate] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:435) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:537) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:192) at org.springframework.beans.factory.annotation.InjectionMetadata.injectMethods(InjectionMetadata.java:117) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:302) ... 40 more Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.springframework.orm.hibernate3.HibernateTemplate] to required type [org.hibernate.SessionFactory] for property 'sessionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.orm.hibernate3.HibernateTemplate] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1289) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1250) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) ... 54 more Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [org.springframework.orm.hibernate3.HibernateTemplate] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231) at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138) at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386) ... 58 more</pre> <p> </p> <p>请问一下这是什么原因,我看网络上好多人都是利用myeclipse自动生成的配置文件搞的,我这个为什么就不行呢?</p> <p>多谢各位大侠</p>
s2sh整合问题 tomcat启动没异常 访问.jsp 和action失败 单独测试struts2成功 hibernate+spring成功
<p>web.xml:</p> <p> </p> <p> </p> <p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p> <p>&lt;web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"</p> <p><span style="white-space: pre;"> </span>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</p> <p><span style="white-space: pre;"> </span>xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;</p> <p> </p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;listener&gt;</p> <p><span style="white-space: pre;"> </span>&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/listener&gt;</p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;context-param&gt;</p> <p><span style="white-space: pre;"> </span>&lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;</p> <p><span style="white-space: pre;"> </span>&lt;param-value&gt;classpath:beans.xml&lt;/param-value&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/context-param&gt;</p> <p><span style="white-space: pre;"> </span>&lt;!--</p> <p><span style="white-space: pre;"> </span>&lt;filter&gt; &lt;filter-name&gt;struts2&lt;/filter-name&gt;</p> <p><span style="white-space: pre;"> </span>&lt;filter-class&gt;org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter&lt;/filter-class&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;struts2&lt;/filter-name&gt;</p> <p><span style="white-space: pre;"> </span>&lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt;</p> <p><span style="white-space: pre;"> </span>--&gt;</p> <p><span style="white-space: pre;"> </span>&lt;filter&gt;</p> <p><span style="white-space: pre;"> </span>&lt;filter-name&gt;struts2&lt;/filter-name&gt;</p> <p><span style="white-space: pre;"> </span>&lt;filter-class&gt;org.apache.struts2.dispatcher.FilterDispatcher&lt;/filter-class&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/filter&gt;</p> <p><span style="white-space: pre;"> </span>&lt;filter-mapping&gt;</p> <p><span style="white-space: pre;"> </span>&lt;filter-name&gt;struts2&lt;/filter-name&gt;</p> <p><span style="white-space: pre;"> </span>&lt;url-pattern&gt;/*&lt;/url-pattern&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/filter-mapping&gt;</p> <p>&lt;/web-app&gt;</p> <p> </p> <p>struts2.xml</p> <p> </p> <p> </p> <p>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;</p> <p>&lt;!DOCTYPE struts PUBLIC</p> <p>    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"</p> <p>    "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;</p> <p> </p> <p>&lt;struts&gt;</p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;constant name="struts.enable.DynamicMethodInvocation" value="true" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;constant name="struts.devMode" value="true" /&gt;</p> <p><span style="white-space: pre;"> </span></p> <p><span style="white-space: pre;"> </span>&lt;package name="useraction" namespace="/user" extends="struts-default"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;action name="userAction" class="userAction"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;result name="success"&gt;/index.jsp&lt;/result&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/action&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/package&gt;</p> <p><span style="white-space: pre;"> </span>&lt;!-- Add packages here --&gt;</p> <p> </p> <p>&lt;/struts&gt;</p> <p> </p> <p>beans.xml</p> <p> </p> <p>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p> <p>&lt;beans xmlns="http://www.springframework.org/schema/beans"</p> <p><span style="white-space: pre;"> </span>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</p> <p><span style="white-space: pre;"> </span>xmlns:context="http://www.springframework.org/schema/context"</p> <p><span style="white-space: pre;"> </span>xmlns:aop="http://www.springframework.org/schema/aop"</p> <p><span style="white-space: pre;"> </span>xmlns:tx="http://www.springframework.org/schema/tx"</p> <p><span style="white-space: pre;"> </span>xsi:schemaLocation="http://www.springframework.org/schema/beans </p> <p>           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd</p> <p>           http://www.springframework.org/schema/context</p> <p>           http://www.springframework.org/schema/context/spring-context-2.5.xsd</p> <p>           http://www.springframework.org/schema/aop</p> <p>           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd</p> <p>           http://www.springframework.org/schema/tx </p> <p>           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&gt;</p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;context:annotation-config /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;context:component-scan base-package="com.kettas"&gt;&lt;/context:component-scan&gt;</p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;!-- datasource --&gt;</p> <p><span style="white-space: pre;"> </span>&lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"</p> <p><span style="white-space: pre;"> </span>destroy-method="close"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;!-- results in a setDriverClassName(String) call --&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="username" value="spc" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="password" value="spc" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/bean&gt;</p> <p><span style="white-space: pre;"> </span>&lt;!-- sessionfactory --&gt;</p> <p><span style="white-space: pre;"> </span>&lt;bean id="sessionFactory"</p> <p><span style="white-space: pre;"> </span>class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="dataSource" ref="dataSource" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="annotatedClasses"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;list&gt;</p> <p><span style="white-space: pre;"> </span>&lt;value&gt;com.kettas.entity.Product&lt;/value&gt;</p> <p><span style="white-space: pre;"> </span>&lt;value&gt;com.kettas.entity.User&lt;/value&gt;</p> <p><span style="white-space: pre;"> </span>&lt;value&gt;com.kettas.entity.Order&lt;/value&gt;</p> <p><span style="white-space: pre;"> </span>&lt;value&gt;com.kettas.entity.Item&lt;/value&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/list&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/property&gt;</p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;property name="hibernateProperties"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;props&gt;</p> <p><span style="white-space: pre;"> </span>&lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.Oracle9Dialect&lt;/prop&gt;</p> <p><span style="white-space: pre;"> </span>&lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;</p> <p><span style="white-space: pre;"> </span>&lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt;</p> <p><span style="white-space: pre;"> </span>&lt;prop key="current_session_context_class"&gt;thread&lt;/prop&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/props&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/property&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/bean&gt;</p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="sessionFactory" ref="sessionFactory" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/bean&gt;</p> <p><span style="white-space: pre;"> </span>&lt;bean id="txManager"</p> <p><span style="white-space: pre;"> </span>class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;property name="sessionFactory" ref="sessionFactory" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/bean&gt;</p> <p><span style="white-space: pre;"> </span>&lt;aop:config&gt;</p> <p><span style="white-space: pre;"> </span>&lt;aop:pointcut id="bussinessService"</p> <p><span style="white-space: pre;"> </span>expression="execution(public * com.biz..*.*(..))" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;aop:advisor pointcut-ref="bussinessService"</p> <p><span style="white-space: pre;"> </span>advice-ref="txAdvice" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/aop:config&gt;</p> <p> </p> <p><span style="white-space: pre;"> </span>&lt;tx:advice id="txAdvice" transaction-manager="txManager"&gt;</p> <p><span style="white-space: pre;"> </span>&lt;tx:attributes&gt;</p> <p><span style="white-space: pre;"> </span>&lt;tx:method name="login" read-only="true" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;tx:method name="select*" read-only="true" /&gt;</p> <p><span style="white-space: pre;"> </span>&lt;tx:method name="insert" propagation="REQUIRED"/&gt;</p> <p><span style="white-space: pre;"> </span>&lt;tx:method name="update" propagation="REQUIRED"/&gt;</p> <p><span style="white-space: pre;"> </span>&lt;tx:method name="delete" propagation="REQUIRED"/&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/tx:attributes&gt;</p> <p><span style="white-space: pre;"> </span>&lt;/tx:advice&gt;</p> <p>&lt;/beans&gt;</p> <p> </p> <p>action:</p> <p> </p> <p>@Controller("userAction")</p> <p>@Scope("prototype")</p> <p>public class UserAction extends ActionSupport {</p> <p><span style="white-space: pre;"> </span>private User user;</p> <p><span style="white-space: pre;"> </span> private UserBiz userBiz;</p> <p><span style="white-space: pre;"> </span>private Map&lt;String, Object&gt; session;</p> <p> </p> <p><span style="white-space: pre;"> </span>public Map&lt;String, Object&gt; getSession() {</p> <p><span style="white-space: pre;"> </span>return session;</p> <p><span style="white-space: pre;"> </span>}</p> <p> </p> <p><span style="white-space: pre;"> </span>public void setSession(Map&lt;String, Object&gt; session) {</p> <p><span style="white-space: pre;"> </span>this.session = session;</p> <p><span style="white-space: pre;"> </span>}</p> <p> </p> <p><span style="white-space: pre;"> </span>public User getUser() {</p> <p><span style="white-space: pre;"> </span>return user;</p> <p><span style="white-space: pre;"> </span>}</p> <p> </p> <p><span style="white-space: pre;"> </span>public void setUser(User user) {</p> <p><span style="white-space: pre;"> </span>this.user = user;</p> <p><span style="white-space: pre;"> </span>}</p> <p> </p> <p><span style="white-space: pre;"> </span> public UserBiz getUserBiz() {</p> <p><span style="white-space: pre;"> </span> return userBiz;</p> <p><span style="white-space: pre;"> </span> }</p> <p><span style="white-space: pre;"> </span></p> <p><span style="white-space: pre;"> </span> @Resource(name = "userBiz")</p> <p><span style="white-space: pre;"> </span> public void setUserBiz(UserBiz userBiz) {</p> <p><span style="white-space: pre;"> </span> this.userBiz = userBiz;</p> <p><span style="white-space: pre;"> </span> }</p> <p> </p> <p><span style="white-space: pre;"> </span>public String login() {</p> <p><span style="white-space: pre;"> </span> User userLogin = userBiz.login(user.getName(), user.getPassword());</p> <p><span style="white-space: pre;"> </span> if (userLogin != null) {</p> <p><span style="white-space: pre;"> </span> session.put("login", userLogin);</p> <p><span style="white-space: pre;"> </span>System.out.println("aaaaaaa");</p> <p><span style="white-space: pre;"> </span> return "success";</p> <p><span style="white-space: pre;"> </span> } else {</p> <p><span style="white-space: pre;"> </span> addActionError("用户名密码错误");</p> <p><span style="white-space: pre;"> </span> return "error";</p> <p><span style="white-space: pre;"> </span> }</p> <p><span style="white-space: pre;"> </span>}</p> <p>}</p> <p> </p>
s2sh整合问题,弄了一天了都没弄出来,拜托大家了!
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [C:\Program Files\apache-tomcat-6.0.28\webapps\System\WEB-INF\classes\applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2722) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at org.springframework.transaction.config.TxAdviceBeanDefinitionParser.getBeanClass(TxAdviceBeanDefinitionParser.java:69) at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:66) at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) ... 37 more Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 55 more 配置文件代码:web.xml [code="java"]<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 开始监听 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配置spring监听器 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:*Context.xml</param-value> </context-param> <filter> <filter-name>openSessionInView</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> <init-param> <param-name>sessionFactoryBeanName</param-name> <param-value>sessionFactory</param-value> </init-param> </filter> <filter-mapping> <filter-name>openSessionInView</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- <filter> <filter-name>lazyLoadingFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> <init-param> <param-name>singleSession</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>lazyLoadingFilter</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> --> <!-- 配置OpenSessionInViewFilter,必须在struts,用来解决could not initialize proxy-no Session报错问题,配置自己写的filter --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- <listener> <listener-class>com.hyit.ttmsoge.listener.FactoryLoaderListener</listener-class> </listener> --> <welcome-file-list> <welcome-file>Login.html</welcome-file> </welcome-file-list> </web-app> [/code] applicationContext: [code="java"]<?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: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/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:8080/ttmsoge"> </property> <property name="username" value="root"></property> <property name="password" value="0429"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </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/hyit/ttmsoge/model/Register.hbm.xml</value> <value>com/hyit/ttmsoge/model/User.hbm.xml</value> </list> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置Advice(事务的传播特性) --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="get*" propagation="SUPPORTS" read-only="true" /> <tx:method name="search*" propagation="SUPPORTS" read-only="true" /> </tx:attributes> </tx:advice> </beans> [/code]
sql server2000与S2SH框架整合思路及注意事项,刚进入这个行业,望指点
自己以前用的oracle\mysql数据库,换工作以后公司数据库是sql server2000的 自己有点儿不适应,很着急
S2SH集成中使用AOP后查询结果为NULL?。。请教高手解答一下
做SSH集成,用得是spring的声明式事务和hibernate做的集成。 以下是spring配置文件中关于AOP的配置: <!-- 配置aop拦截声明类 --> <bean id = "myAop" class="com.acc.aop.MyAop"></bean> <aop:config> <aop:pointcut expression="execution(* com.acc.service.*.*(..))" id="pointCut"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="pointCut"/> <!-- 配置切面 --> <aop:aspect id="aspect" ref="myAop"> <aop:after method="after" pointcut-ref="pointCut"/> <aop:after-returning method="afterReturning" pointcut-ref="pointCut"/> <!--环绕 --> <aop:around method="arroundAdvice" pointcut-ref="pointCut"/> <aop:before method="beforeAdvice" pointcut-ref="pointCut"/> </aop:aspect> </aop:config> 之后是从Dao 层 ---》service层----》action层逐层注入的,在action中查询结果集,调用注入在action层中的service层接口,执行数据查询操作时,查询的结果为NUll!!!! 我试了一下把上面配置文件中的`<aop:aspect id="aspect" ref="myAop"></sop:aspect>`标签中配置的环绕通知配置项注释掉后,可以查询出结果集. 一下是自定义的aop类中的环绕方法: public void arroundAdvice(ProceedingJoinPoint pjp){ System.out.println("环绕通知"); try { pjp.proceed(); } catch (Throwable e) { e.printStackTrace(); } } 为什么注释了配置文件中有关于环绕通知的配置后就可以查询出结果集了?? <!--环绕 --> <aop:around method="arroundAdvice" pointcut-ref="pointCut"/> 不懂了,恳请各位帮忙解决!
struts2+Hibernate+spring整合问题(异常
异常信息: exception Unable to instantiate Action, loginAction, defined for 'loginAction' in namespace '/'loginAction com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318) com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399) com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198) org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) root cause java.lang.ClassNotFoundException: loginAction org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157) com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:107) com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:223) com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:143) com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150) com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120) com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299) com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399) com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198) org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) 导入的jar文件: [img]http://dl.iteye.com/upload/picture/pic/90617/97d45138-0021-3cbe-a1a1-167ab1e0cc8c.jpg[/img] [img]http://dl.iteye.com/upload/picture/pic/90615/be54d974-693d-3ac1-b742-f9902c0c6969.jpg[/img] web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> applicationContext.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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://localhost:3306/test"></property> <property name="username" value="root"></property> <property name="password" value=""></property> <property name="maxActive" value="100"></property> <property name="maxIdle" value="30"></property> <property name="maxWait" value="500"></property> <property name="defaultAutoCommit" value="true"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>com/gufengxiachen/s2sh/bean/User.hbm.xml</value> </list> </property> </bean> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <constructor-arg> <ref local="sessionFactory"/> </constructor-arg> </bean> <!-- 把DAO注入给Session工厂 --> <bean id="userDao" class="com.gufengxiachen.s2sh.daoimpl.UserDAOImpl" > <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <!-- 把Service注入给DAO --> <bean id="userService" class="com.gufengxiachen.s2sh.serviceimpl.UserServiceImpl"> <property name="userDao" ref="userDao"> </property> </bean> <!-- 把Action注入给Service --> <bean id="loginAction" class="com.gufengxiachen.s2sh.action.LoginAction"> <property name="userService" ref="userService"> </property> </bean> </beans> struts.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <package name="s2sh" extends="struts-default" namespace="/"> <action name="loginAction" class="loginAction"> <result name="success">/result.jsp</result> <result name="input">/index.jsp</result> </action> </package> </struts> hibernate映射文件: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.gufengxiachen.s2sh.bean" table="user"> <id name="id" column="id" type="int"> <generator class="increment"></generator> </id> <property name="username" column="username" type="string"></property> <property name="password" type="string"></property> </class> </hibernate-mapping>
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
【JSON解析】浅谈JSONObject的使用
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
立即提问