struts2 查看页面源代码<s:property value="#name"/>值是unicode编码?怎样显示正常的中文

struts2 查看页面源代码值是unicode编码?怎样显示正常的中文。

5个回答

根据你代码和JSP页面的编码来的,两边设的一致即可(中文的话通常是GBK,UTF-8)

<%@ page contentType="text/html; charset=UTF-8" %>

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%@ page pageEncoding="utf-8"%>

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
spring会自动代理Struts2的action

我的struts的action全部被spring配置成了aop,我的action出现的全部是代理对象。 导致我的action不能调用自己定义的方法。为什么我没有配置struts的action为aop, 但是spring全部自动配置成了aop?这spring的配置文件 ``` <?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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 启用注解扫描 --> <context:annotation-config/> <!-- spring默认只代理Action类的接口的函数,cglib jar文件就是可以代理Action自己定义的函数 <aop:aspectj-autoproxy proxy-target-class="true" /> --> <bean id="testService" class="com.guoqiao.test.TestService"> <property name="name" value="test"/> </bean> <!-- 配置数据源 --> <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:@127.0.0.1:1521:orclguo"/> <property name="username" value="scott"/> <property name="password" value="tiger"/> <!-- 连接池启动时的初始值 --> <property name="initialSize" value="30"/> <!-- 连接池的最大值 --> <property name="maxActive" value="500"/> <!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --> <property name="maxIdle" value="2"/> <!-- 最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --> <property name="minIdle" value="1"/> </bean> <!-- 配置会话工厂() --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 设置数据源 --> <property name="dataSource" ref="dataSource"/> <!-- 接管了hibernate对象映射文件 --> <property name="mappingResources"> <list> <value>com/guoqiao/domain/Department.hbm.xml</value> <value>com/guoqiao/domain/Employee.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <value> hibernate.dialect=org.hibernate.dialect.OracleDialect hibernate.hbm2ddl.auto=update hibernate.show_sql=true hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=true hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.generate_statistics=true </value> </property> </bean> <!-- <bean id="employeeService" class="com.guoqiao.service.imp.EmployeeService"> <property name="sessionFactory" ref="sessionFactory" /> </bean> --> <!-- 配置EmployeeService对象通过注解的方式来注入属性值,这是一个知识点 --> <bean id="employeeService" class="com.guoqiao.service.imp.EmployeeService"/> <bean id="departmentService" class="com.guoqiao.service.imp.DepartmentService"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 配置事务管理器,统一管理sessionFactory的事务 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 启用事务注解 @Transactional--> <tx:annotation-driven transaction-manager="txManager"/> </beans> ``` 明白点说就是我spring中的bean全部都被spring代理了,包括我struts2的action. 举个例子,我有个叫employee的bean ``` <bean id="employeeService" class="com.guoqiao.service.imp.EmployeeService"> <property name="sessionFactory" ref="sessionFactory" /> </bean> ``` public interface EmployeeServiceInterf{ public void a(); } public class EmpolyeeService implements EmployeeServiceInterf{ public void b(){ System.out.println("b"); }; public void a(){ System.out.println("a"); }; } public class TestInjection(){ //下面的写法注入不了 EmpoyeeService employeeService; //下面的写法可以注入 EmpoyeeServiceInterf employeeService; } 这是一个bean,这个Bean类是EmpoyeeService EmpoyeeService实现了EmployeeServiceInterf接口 但我是把这个bean注入类型为EmpoyeeService的对象上会注入失败 把这个bean注入EmployeeServiceInterf的对象上时才能成功(在spring集成struts2的环境中) 再明白点说就是说这个bean看起来像是一个实现类,但其实你用这bean注入其他对象 上的时候,这个bean是这个实现类的代理对象。 如果上面我手动写的代码还看不懂的话,你还是绕道吧,你连我讲的是什么都看不懂。

昨天正常,今天不正常的问题 Error creating bean with name 'sessionFactory'

[size=large]这样的配置用了好久了,一直没出状况,今天突然出状况了,而且重新集成ssh框架后也是同样的错误,郁闷中...,MyEclipse启动tomcat就报错,不知所谓何? 贴出来请教下有遇到此问题的大侠:[/size] 平台采用ssh框架,集成环境的jar包是用MyEclipse8.0M2自动创建, [img]http://dl.iteye.com/upload/attachment/188763/761d5160-fb8c-3b87-bbbb-c9e23a7c008f.png[/img] 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" 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-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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 定义数据源Bean --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://127.0.0.1:3306/task_system?useUnicode=true&amp;characterEncoding=UTF-8"> </property> <property name="username" value="root"></property> <property name="password" value="1234"></property> </bean> <!--定义了Hibernate的SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.jdbc.batch_size">20</prop> </props> </property> <property name="mappingResources"> <list> <value>/pojo/UserDept.hbm.xml</value> <value>/pojo/UserEmployee.hbm.xml</value> <value>/pojo/UserJob.hbm.xml</value> </list> </property> </bean> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 报错: 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) [b]问题补充:[/b] 问题解决了,是我不知道什么时候把jsp页面的struts标签里加个html标签了,肯定是放错位置了,后来纠正后,又不小心还原了一下吧,所以没发现,今天看了楼下的朋友的答案,提醒了我,在jsp页面里把代码分段删除测试,终于发现问题之所在了。谢谢您的热心,多亏您提醒我。

There is no Action mapped for namespace

使用的是J2EE+SHH框架, 具体代码如下: --- **struts.xml** ``` <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant name="struts.custom.i18n.resources" value="message" /> <constant name="struts.i18n.encoding" value="UTF-8" /> <!-- 指定Struts 2默认的ObjectFactory Bean - 交给Spring管理 --> <constant name="struts.objectFactory" value="spring" /> <!-- 开发者模式 --> <!-- <constant name="struts.devMode" value="true" /> --> <!-- 指定每次配置文件更改后,自动重新加载 --> <constant name="struts.configuration.xml.reload" value="false" /> </struts> ``` --- **applicationContext.xml** ``` **<?xml version="1.0" encoding="UTF-8"?> <!-- context是自动扫描和使用注解的上下文前缀;aop,tx是事物管理的前缀 -->** <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" 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:task="http://www.springframework.org/schema/task" 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 http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd" default-autowire="byName"> <!-- 采用自动扫描的方式查找bean(DAO,Service等等),多个用逗号隔开 --> <context:component-scan base-package="com.cheer.bookshop" /> <!-- 定时器任务 --> <task:annotation-driven /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <description>配置数据源</description> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://localhost:3306/bookstore?useUnicode=true&amp;characterEncoding=UTF-8"></property> <property name="username" value="root"></property> <property name="password" value="123456"></property> <!-- 初始化连接数量 --> <property name="initialSize" value="1"/> <!-- 最大活动连接数量,一般等于数据库的最大并发数 --> <property name="maxActive" value="100"/> <!-- 最大空闲(等待)连接数量 --> <property name="maxIdle" value="-1"/> <!-- 最小空闲(等待)连接数量 --> <property name="minIdle" value="0"/> <!-- 获取连接时等待时间,超出将抛异常,单位毫秒 --> <property name="maxWait" value="10000"/> </bean> <!-- 配置hibernate session工厂 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <description>将数据源注入到sessionFactory,使用注解方式</description> <property name="dataSource" ref="dataSource"></property> <!-- 配置hibernate的一些属性 --> <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.current_session_context_class">thread</prop> <prop key="hibernate.connection.release_mode">after_transaction</prop><!-- 释放session --> </props> </property> <!-- 自动扫描注解方式配置的hibernate映射文件(实体类) --> <property name="packagesToScan"> <list> <value>com.cheer.bookshop.Model</value> </list> </property> </bean> <!-- 定义事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <description> 增加事务管理</description> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 拦截器方式配置事务特性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <!-- 给business配置事务管理 --> <aop:config proxy-target-class="true"> <aop:pointcut id="allManagerMethod" expression="execution (* com.cheer.bookshop.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" /> </aop:config> </beans> ``` --- **JSP页面登陆Form表单** ``` <s:form action="userlogin.action" method="post"> <p><font color="red">&nbsp;&nbsp;&nbsp;${msg}</font></p> <div class="form_row"> <label class="contact"><strong>Username:</strong></label> <input type="text" class="contact_input" name="user.username" value="${user.username}"/> </div> <div class="form_row"> <label class="contact"><strong>Password:</strong></label> <input type="password" class="contact_input" name="user.password" value="${user.password}"/> </div> <div class="form_row"> <div class="terms"> <input type="checkbox" name="terms" /> Remember me </div> </div> <div class="form_row"> <input type="submit" class="register" value="login" /> </div> </s:form> ``` --- **Action类** ``` package com.cheer.bookshop.action; import java.io.IOException; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.ServletActionContext; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import com.cheer.bookshop.Model.User; import com.cheer.bookshop.service.impl.UserServiceImpl; import com.opensymphony.xwork2.ActionSupport; @Namespace("/") public class UserAction extends ActionSupport { @Resource private UserServiceImpl userServiceImpl; private User user; private String msg; //用户登录 @Action(value = "userlogin", results = {@Result(name = "success", location = "/index.jsp"), @Result(name = "input", location = "/jsp/user/myaccount.jsp", type = "redirect") }) public String login(){ User userdb = userServiceImpl.login(user.getUsername()); if(userdb != null){ String password = user.getPassword(); if(password.equals(userdb.getPassword())){ user=userdb; return SUCCESS; }else{ msg="密码错误,请重新输入!"; return INPUT; } }else{ msg="用户名不存在,请注册!"; return INPUT; } } //用户注册 @Action(value = "userregister", results = {@Result(name = "success", location = "/jsp/user/myaccount.jsp", type = "redirect") }) public String register(){ userServiceImpl.register(user); return SUCCESS; } //验证用户名是否已经被使用 @Action(value = "validateUsername") public String validateUsername() throws IOException{ HttpServletRequest request = ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html;charset=UTF-8"); String username = request.getParameter("username"); boolean flag = userServiceImpl.validateUsername(username); if(flag){ response.getWriter().println("<p><font color='red'>用户名已经存在</font></p>"); }else{ response.getWriter().println("<p><font color='green'>用户名可以使用</font></p>"); } return NONE; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } } ``` --- 如上,Action有配置userlogin,登陆页form表单提交路径也是一样,单就是无法调整至aciton里,eclipse也没有报错,该如何解决? There is no Action mapped for namespace / and action name userlogin.

struts2+spring+mybatis 程序不报错,但是数据无法写入数据库

执行到service 无法写入数据库,不报错。代码如下: ``` <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="app.login.dao.UserDao"> <resultMap type="app.login.domain.User" id="userResult"> <result property="id" column="id" jdbcType="INTEGER" javaType="java.lang.Integer" /> <result property="username" column="username" /> <result property="password" column="password" /> </resultMap> <select id="queryUserForLogin" parameterType="user" resultMap="userResult"> select * from user where username=#{username} and password=#{password} </select> <select id="selectAllUser" resultMap="userResult"> select * from user </select> ``` ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <typeAliases> <typeAlias alias="user" type="app.login.domain.User"/> <typeAlias alias="sysLog" type="app.log.domain.SysLog"/> </typeAliases> <mappers> <mapper resource="app/login/domain/User.xml" /> <mapper resource="app/log/domain/SysLog.xml" /> </mappers> </configuration> ``` ackage app.log.dao; import java.util.List; import app.log.domain.SysLog; public interface ILogDao { public abstract void insertLog(SysLog sysLog); ``` ackage app.log.dao; import java.util.List; import app.log.domain.SysLog; public interface ILogDao { public abstract void insertLog(SysLog sysLog); public abstract void updateLog(SysLog sysLog); public abstract void deleteLog(SysLog sysLog); public abstract List<SysLog> findAll(); } ``` ``` package app.log.service.impl; import java.util.List; import app.log.dao.ILogDao; import app.log.domain.SysLog; import app.log.service.ILogService; public class LogService implements ILogService { private ILogDao logDao; @Override public void addLog(SysLog sysLog) { // TODO Auto-generated method stub System.out.println("addLog service....."); logDao.insertLog(sysLog); System.out.println("addLog service over....."); } @Override public void updateLog(SysLog sysLog) { // TODO Auto-generated method stub logDao.updateLog(sysLog); } @Override public void deleteLog(SysLog sysLog) { // TODO Auto-generated method stub logDao.deleteLog(sysLog); } @Override public List<SysLog> findAllUser() { // TODO Auto-generated method stub return logDao.findAll(); } public ILogDao getLogDao() { return logDao; } public void setLogDao(ILogDao logDao) { this.logDao = logDao; } } ``` ``` <?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/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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- 数据库配置文件位置 --> <context:property-placeholder location="classpath:jdbc.properties" /> <!-- 配置dbcp数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- 队列中的最小等待数 --> <property name="minIdle" value="${jdbc.minIdle}"></property> <!-- 队列中的最大等待数 --> <property name="maxIdle" value="${jdbc.maxIdle}"></property> <!-- 最长等待时间,单位毫秒 --> <property name="maxWait" value="${jdbc.maxWait}"></property> <!-- 最大活跃数 --> <property name="maxActive" value="${jdbc.maxActive}"></property> <property name="initialSize" value="${jdbc.initialSize}"></property> </bean> <!-- 配置mybitasSqlSessionFactoryBean --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:mybatis.xml"></property> </bean> <bean id="userDao" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="mapperInterface" value="app.login.dao.UserDao"/> <property name="sqlSessionFactory" ref="sqlSessionFactory" /> </bean> <bean id="userService" class=" app.login.service.impl.UserService"> <property name="userDao" ref="userDao"></property> </bean> <bean id="loginAction" class="app.login.action.LoginAction"> <property name="userService" ref="userService"></property> </bean> <bean id="logDao" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="mapperInterface" value="app.log.dao.ILogDao"/> <property name="sqlSessionFactory" ref="sqlSessionFactory" /> </bean> <bean id="logService" class=" app.log.service.impl.LogService"> <property name="logDao" ref="logDao"></property> </bean> </beans> ``` ``` ```

spring 注解方面的疑惑

小弟最近刚刚接触ssh2整合 ,有2个问题没弄明白,希望各位高手 指教一下,小弟不胜感激 下面把我的代码先贴出来 [color=red]user.java[/color] public class User { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } [color=red]user.hbm.xml[/color] <?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 package="cn.com.jyp.model"> <class name="User" table="j_user"> <id name="id"> <generator class="native" /> </id> <property name="name" /> </class> </hibernate-mapping> [color=red]UserDao[/color] public interface UserDao { /** * 添加 */ public void save(User user); [color=red]UserDaoImpl[/color] @Repository("userDao") public class UserDaoImpl extends HibernateDaoSupport implements UserDao { @Resource(name = "hibernateTemplate") public void setHibernateTemplate1(HibernateTemplate hibernateTemplate) { super.setHibernateTemplate(hibernateTemplate); } /* * 添加 */ public void save(User user) { getHibernateTemplate().save(user); } [color=red]UserService[/color] public interface UserService { /** * 注册用户 */ public void save(User user); [color=red]UserServiceImpl[/color] @Service("userService") @Transactional public class UserServiceImpl implements UserService { @Resource private UserDao userDao; /* * 注册用户 */ public void save(User user) { if (user != null && user instanceof Object) userDao.save(user); } [color=red]struts.xml[/color] <?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> <constant name="struts.objectFactory" value="spring" /> <package name="User" extends="struts-default"> <action name="userAdd" class="userAddAction"> <result name="success" >/success.jsp</result> <result name="input">/userAdd.jsp</result> </action> </package> </struts> [color=red]applicationContext.xml[/color] <?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:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- spring自动扫描和管理bean --> <context:component-scan base-package="cn.com.jyp"/> <!-- 配置数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/ssh2" /> <property name="username" value="root" /> <property name="password" value="root" /> </bean> <!-- 配置SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value>cn/com/jyp/model/User.hbm.xml</value> </list> </property> </bean> <!-- 配置hibernateTemplate --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置spring提供的事务管理器 --> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- 采用@Transactional注解方式使用事务 --> <tx:annotation-driven transaction-manager="txManager"/> </beans> 我的疑问是,第一个:在使用Spring提供的注解方式@Resource 注入依赖对象,标注在属性上,是不是可以不用提供这个属性的setter方法,如果可以不提供的话,为什么UserDaoImpl 里 这么写 @Resource private HibernateTemplate hibernateTemplate; 确出错,这个注解的实现原理是不是根据相应的属性自动提供其setter方法为其注入的啊 ? 第二个:关于事务的注解是按照上面的代码这么标在service上吧? 第三个:就是请各位帮我看看我的代码不足之处 谢谢了!

springmvc+hibernate整合事务不回滚,求解

最近心血来潮研究下了springmvc,发现比struts2好用多了,配置也方便,捣鼓了一阵,最后想把hibernate也整进去,结果悲剧就来了,事务就是不回滚,实在没招了,哪位大侠给看下,上代码 springmvc-servlet.xml [code="java"]<mvc:annotation-driven/> <!-- 扫描注解时,将service,DAO层的注解排除,只扫描Controller注解 --> <context:component-scan base-package="com.springmvc" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" /> </context:component-scan> <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="html" value="text/html" /> <entry key="json" value="application/json" /> </map> </property> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" /> </bean> </list> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> </list> </property> </bean>[/code]applicationContext-db.xml [code="java"]<context:annotation-config /> <context:component-scan base-package="com.springmvc" /> <!-- 配置数据源 --> <bean id = "mappings" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations" value="classpath:dataSources.properties"></property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="${driverClassName}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <property name="maxActive" value="${maxActive}" /> <property name="maxIdle" value="${maxIdle}" /> <property name="maxWait" value="${maxWait}" /> <property name="defaultAutoCommit" value="${defaultAutoCommit}" /> </bean> <!-- 配置sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <!-- 扫描的domain包路径 --> <property name="packagesToScan" value="com.springmvc.domain"/> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">none</prop> <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop> <prop key="hibernate.search.default.transaction.merge_factor">100</prop> <prop key="hibernate.search.default.transaction.max_buffered_docs">100</prop> <prop key="hibernate.search.autoregister_listeners">true</prop> <prop key="hibernate.search.indexing_strategy">manual</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"/> </bean> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>[/code]applicationContext-aop.xml[code="java"]<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="create*" propagation="REQUIRED"/> <tx:method name="do*" propagation="REQUIRED"/> <tx:method name="del*" propagation="REQUIRED"/> <tx:method name="remove*" propagation="REQUIRED"/> <tx:method name="get*" read-only="true" /> <tx:method name="query*" read-only="true" /> <tx:method name="find*" read-only="true" /> <tx:method name="*"/> </tx:attributes> </tx:advice> <aop:config proxy-target-class="true"> <aop:pointcut expression="execution(public * com.springmvc.service.impl.*ServiceImpl.*(..))" id="allServiceMethod"/> <aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" /> </aop:config>[/code]UserServiceImpl[code="java"]Service(value = "userService") @Transactional(rollbackFor=Exception.class) public class UserServiceImpl implements UserService { @Autowired private UserDAO userDAO; @Override public void addUser(User user) { userDAO.addUser(user); } }[/code]UserDAOImpl [code="java"]@Repository(value = "userDAO") public class UserDAOImpl extends HibernateDaoSupport implements UserDAO { private Logger logger = Logger.getLogger(getClass()); @Override public void addUser(User user) { logger.debug("新增用户"); this.getHibernateTemplate().save(user); }[/code]UserServiceTest[code="java"]@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"file:webroot/WEB-INF/springmvc-servlet.xml","classpath:applicationContext-*.xml"}) public class UserServiceTest{ @Autowired private UserService userService; @Test public void testAddUser() { User user1 = new User(); user1.setCode("A002"); user1.setName("haha"); userService.addUser(user1); User user2 = new User(); user2.setCode("A001"); user2.setName("haha"); userService.addUser(user2); User user3 = new User(); user3.setCode("A001");//code是唯一的,这里报唯一约束错误,前面两条数据是不是应该插入失败? user3.setName("haha"); userService.addUser(user3); } }[/code]

fckeditor的格式怎么显示到前台jsp

项目是ssh做的 找着网上直接在jsp里面添加下面代码,然后出来编辑器了,可是提交了后显示的是html源代码 这是加在jsp中的代码 [code="java"]<%@ page language="java" pageEncoding="gb2312"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>首页 》 日志 》 创建日志</title> <script type="text/javascript" src="../fckeditor/fckeditor.js"></script> <script type="text/javascript"> window.onload = function() { // Automatically calculates the editor base path based on the _samples directory. // This is usefull only for these samples. A real application should use something like this: // oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. //var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ; var sBasePath = "http://localhost:8080/blog/fckeditor/" var oFCKeditor = new FCKeditor( 'diaryContent' ) ; oFCKeditor.BasePath = sBasePath ; oFCKeditor.ReplaceTextarea() ; } </script> </head> <body> <center> <form action="addDiary.action" method="post" enctype="multipart/form-data"> <br> <p align="left"> <table> <tr><td>日志标题:</td><td><input type="text" name="diaryTitle" /></td></tr> </table> <br><br> 日志内容:<br> <textarea style="font-size:15px" name="diaryContent" cols ="100" rows = "20"></textarea><br><br> <input value="提交" type="submit" /> </form> </center> </body> </html>[/code] 这是没添加fckeditor编辑器之前,从数据库中取出diaryContent的代码 [code="java"]<td>内容: <s:property value="diaryContent" /> </td>[/code] 显示页面 [quote]<p><u><em>sadff</em></u></p> [/quote] 这个地方怎么改,才能在jsp页面上显示格式,而不是源代码,谢谢

Struts2与Hibernate整合时无法读取数据库中的数据

小弟最近学习SSH框架,遇到一个问题,同时使用Struts2和Hibernate3.6时,Action中调用hibernateUtil的方法无法获取数据,而在测试类的main()方法里却能成功调用,小弟百思不得其解,恳请各位大神指点。 关键源代码如下: 业务逻辑ShowStuAction: ``` public class ShowStuAction extends ActionSupport { private int page ; private List<Student> result; public static void main(String args[]){ List<Student> result = HibernateUtil.queryByPage("select stu from Student as stu",null,2, 20); System.out.println(result.size()); for(Student s: result){ System.out.println("学号" + s.getStu_no()); System.out.println("姓名: " + s.getStu_name()); } } public String execute(){ result = HibernateUtil.queryByPage("select stu from Student as stu",null,1,20); if(result.isEmpty()){ System.out.println("Result is Empty"); } return "success"; } ``` hibernateUtil类关键代码: ``` public class HibernateUtil { private static SessionFactory sessionFactory; /** * @return 获取会话工厂 */ public static SessionFactory getSessionFactory() { //读取Hibernate的配置文件 hibernamte.cfg.xml文件 Configuration con=new Configuration().configure(); SessionFactory sessionFactory=con.buildSessionFactory(); return sessionFactory; } /** * @return 获取会话对象 */ public static Session getSession() { return getSessionFactory().openSession(); } /** * @param <T> * @param sql * @param param * @param page * @param size * @return 实现分页查询 */ @SuppressWarnings("unchecked") public static <T> List<T> queryByPage(String sql,String[] param,int page,int size) { System.out.println("QueryByPage"); List<T> list=new ArrayList<T>(); Session session=null; try { session=getSession(); Query query=session.createQuery(sql); if(param!=null) { for(int i=0;i<param.length;i++) { query.setString(i,param[i]); } } //筛选条数 query.setFirstResult((page - 1) * size); query.setMaxResults(size); list=query.list(); for(Object t : query.list()){ System.out.println("nima"); System.out.println(t.toString()); } } catch (Exception e) { } finally { if(session!=null) { session.close(); } } return list; } ``` hibernate3.6配置文件 ``` <hibernate-configuration> <session-factory> <property name="connection.driver">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/whu</property> <property name="connection.username">root</property> <property name="connection.password">123456</property> <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.cache.use_second_level_cache" >false</property> <mapping resource="pojo/Student.hbm.xml"/> </session-factory> </hibernate-configuration> ``` Struts2 配置文件 ``` <struts> <constant name="struts.configuration.xml.reload" value="true" /> <constant name="struts.devMode" value="true" /> <package name="stu" extends="struts-default"> <action name="showStu" class="action.ShowStuAction" method="execute"> <result name="success" >/content/show-stu-success.jsp</result> </action> </package> </struts> ``` 运行时,ShowStuAction中的main()方法可以成功地获取数据,而execute()方法中的数据总是空的,后台没有报错。

学ssh整合时遇到Error creating bean with name xxx问题,向大家请教

ssh整合,测试时遇到Error creating bean with name xxx问题,这个问题之前看到有很多人问,但是貌似没有什么解决方案。 跪求大佬们指点一二 这是完整的Debug错误信息: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testService' defined in file [E:\MyEclipseworkplace\Test2\WebRoot\WEB-INF\classes\cn\itcast\oa\test\TestService.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at cn.itcast.oa.test.SpringTest.<init>(SpringTest.java:10) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:209) at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:258) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:255) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer at org.springframework.aop.framework.Cglib2AopProxy.createEnhancer(Cglib2AopProxy.java:228) at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:170) at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ... 34 more 我的Spring配置文件如下: <?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: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/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <!-- 自动扫描与装配bean --> <context:component-scan base-package="cn.itcast.oa"></context:component-scan> <!-- 配置数据库连接池(c3p0) --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <!-- 基本信息 --> <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/itcastoa"></property> <property name="driverClass" value="com.mysql.jdbc.Driver"></property> <property name="user" value="root"></property> <property name="password" value="966536"></property> <!-- 其他配置 --> <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 --> <property name="initialPoolSize" value="3"></property> <!--连接池中保留的最小连接数。Default: 3 --> <property name="minPoolSize" value="3"></property> <!--连接池中保留的最大连接数。Default: 15 --> <property name="maxPoolSize" value="5"></property> <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --> <property name="acquireIncrement" value="3"></property> <!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 --> <property name="maxStatements" value="8"></property> <!-- maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 --> <property name="maxStatementsPerConnection" value="5"></property> <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --> <property name="maxIdleTime" value="1800"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <!-- 配置声明式的事务管理(采用基于注解的方式) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> </beans> 我的测试代码如下: package cn.itcast.oa.test; import org.hibernate.SessionFactory; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class SpringTest { private ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); // 测试SessionFactory @Test public void testSessionFactory() throws Exception { SessionFactory sessionFactory = (SessionFactory) ac.getBean("sessionFactory"); System.out.println(sessionFactory); } // 测试事务 @Test public void testTransaction() throws Exception { TestService testService = (TestService) ac.getBean("testService"); testService.saveTwoUsers(); } }

spring 注入问题

<div class="iteye-blog-content-contain" style="font-size: 14px;"> <p>直接粘代码吧</p> <div class="quote_title">applicationContext.xml 写道</div> <div class="quote_div">&lt;!-- 加载相关配置文件 --&gt;<br> &lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;<br> &lt;property name="locations"&gt;<br> &lt;list&gt;<br> &lt;value&gt;classpath:applicationContext.properties&lt;/value&gt;<br> &lt;/list&gt;<br> &lt;/property&gt;<br> &lt;/bean&gt;<br><br> &lt;!-- DBCP 数据源 配置--&gt;<br> &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;<br> &lt;!--JDBC驱动程序类名 --&gt;<br> &lt;property name="driverClassName" value="${jdbc.driverClassName}"/&gt;<br> &lt;!--连接字符串 --&gt;<br> &lt;property name="url" value="${jdbc.url}"/&gt;<br> &lt;!--数据源用户名 --&gt;<br> &lt;property name="username" value="${jdbc.username}"/&gt;<br> &lt;!--数据源密码 --&gt;<br> &lt;property name="password" value="${jdbc.password}"/&gt;<br> &lt;/bean&gt;<br><br> &lt;!-- Hibernate相关 --&gt;<br> &lt;bean id="sessionFactory"<br> class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;<br> &lt;property name="dataSource" ref="dataSource" /&gt;<br> &lt;property name="annotatedClasses"&gt;<br> &lt;list&gt;<br> &lt;value&gt;com.xixi.school.model.Player&lt;/value&gt;<br> &lt;/list&gt;<br> &lt;/property&gt;<br> &lt;property name="hibernateProperties"&gt;<br> &lt;props&gt;<br> &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;<br> &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt;<br> &lt;prop key="hibernate.autoCommit"&gt;true&lt;/prop&gt;<br> &lt;/props&gt;<br> &lt;/property&gt;<br> &lt;/bean&gt;<br><br> &lt;!-- 加载其他配置文件--&gt;<br> &lt;import resource="classpath*:applicationContext-*.xml"/&gt;</div> <div class="quote_div"> <div class="quote_title">applicationContext-player.xml 写道</div> <div class="quote_div">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>&lt;beans xmlns="http://www.springframework.org/schema/beans"<br> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"&gt;<br><br> &lt;bean id="playerDao" class="com.xixi.school.dao.impl.PlayerDaoImpl"&gt;<br> &lt;property name="sessionFactory" ref="sessionFactory"/&gt;<br> &lt;/bean&gt;<br><br> &lt;!-- service --&gt;<br> &lt;bean id="playerService" class="com.xixi.school.service.impl.PlayerServiceImpl"&gt;<br> &lt;property name="playerDao" ref="playerDao" /&gt;<br> &lt;/bean&gt;<br>&lt;/beans&gt;</div>  上面为spring 两个配置文件 </div> <div class="quote_div"> <pre name="code" class="java">/** * */ private static final long serialVersionUID = 1L; private IPlayerService playerService; private Player player; public String savePlayer(){ playerService.savePlayer(player); return SUCCESS; } public Player getPlayer() { return player; } public void setPlayer(Player player) { this.player = player; } public void setPlayerService(PlayerServiceImpl playerService) { this.playerService = playerService; }</pre> <pre name="code" class="struts2 Action"> <span style="font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 1.5;"> 上面为struts2 的Action  </span><span style="font-size: 1em; line-height: 1.5;">private IPlayerService playerService; 是spring 注入. </span><span style="font-size: 1em; line-height: 1.5; white-space: normal;">  项目启动时,能访问到action,对象Player可以得到页面提交值,但</span><span style="font-size: 1em; line-height: 1.5; white-space: normal;">playerService一直报NPE错? </span></pre> </div> <div class="quote_div"> </div> <p> </p> </div>

初学hibernate,简单地用了一下SSH2,出现一种难明的错误

用《开发者突击》里面的初步搭建SSH2的代码,连接sqlserver2005,出现下面提示: Hibernate: select user0_.ID as ID, user0_.username as username0_, user0_.password as password0_, user0_.email as email0_ from user user0_ where user0_.username=? WARN - SQL Error: 156, SQLState: S0001 ERROR - 关键字 'user' 附近有语法错误。 2010-12-28 22:22:11 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet default threw exception com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'user' 附近有语法错误。 数据库中我建了表 user,属性有id username password email。 applicationContext 代码如下: [code="xml"] <!-- 配置数据源 --> <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=DeviceManagement;"> </property> <property name="username" value="sa"></property> <property name="password" value="123456"></property> </bean> <!-- 配置Hibernate --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="mappingResources"> <list> <value>com/demo/hibernate/beans/User.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.SQLServerDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <!-- 配置事务 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!-- 定义DAO --> <bean id="userDAO" class="com.demo.hibernate.dao.UserDAO"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <!-- 定义DAO代理 --> <bean id="UserDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"> <ref bean="transactionManager" /> </property> <property name="target"> <ref local="userDAO" /> </property> <property name="transactionAttributes"> <props> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <!-- 定义Struts配置 --> <bean name="loginAction" class="com.demo.struts2.actions.LoginAction"> <property name="userDAO"> <ref local="userDAO" /> </property> </bean> <bean name="logoutAction" class="com.demo.struts2.actions.LogoutAction"> <property name="userDAO"> <ref local="userDAO" /> </property> </bean> <bean name="registerAction" class="com.demo.struts2.actions.RegisterAction"> <property name="userDAO"> <ref local="userDAO" /> </property> </bean> <!-- 配置拦截器 --> <bean name="logger" class="com.demo.spring.aop.LoggingInterceptor" /> <!-- 配置拦截器代理 --> <bean name="loggingAutoProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="beanNames"> <list> <value>/login</value> <value>/register</value> </list> </property> <property name="interceptorNames"> <list> <value>logger</value> </list> </property> </bean> [/code] [size=x-large]提示错误行在UserDao里面, [/size]UserDao [code="java"] package com.demo.hibernate.dao; import java.util.ArrayList; import java.util.List; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.criterion.Restrictions; import org.springframework.orm.hibernate3.HibernateCallback; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; import com.demo.hibernate.beans.User; public class UserDAO extends HibernateDaoSupport implements IUserDAO { // 验证用户名和密码 public boolean isValid(final String username, final String password) { System.out.println("UserDao检验是否有效"); System.err.println("username:"+username+",password:"+password); List list = (List) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { /////////////////////////////////////这里报错/////////////////////////////// List result = session.createCriteria(User.class).add( Restrictions.eq("username", username)).add( Restrictions.eq("password", password)).list(); return result; } }); if (list.size() > 0) { return true; } else { return false; } } // 判断某个用户是否存在,只需用用户名查询就可以 public boolean isExist(final String username) { System.err.println("UserDao进行查询"); List list = (List) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { List result = session.createCriteria(User.class).add( Restrictions.eq("username", username)).list(); return result; } }); if (list.size() > 0) { return true; } else { return false; } } //插入新的用户对象到数据库 public void insertUser(User user) { System.err.println("UserDao插入数据"); getHibernateTemplate().saveOrUpdate(user); } //从数据库中取得用户对象 public User getUser(String userid) { System.err.println("UserDao取得对象"); return (User) getHibernateTemplate().get(User.class, new Integer(userid)); } //取得用户所有详细信息 public List getUsers() { System.err.println("UserDao取得数据"); return getHibernateTemplate().find("from User"); } //删除某个用户的所有信息 public void deleteUser(String userid) { System.err.println("UserDao删除某个用户的所有信息"); Object p = getHibernateTemplate().load(User.class, new Integer(userid)); getHibernateTemplate().delete(p); } } [/code] 请问这是为什么呢?

SSH 框架搭建时出的错误 Exception sending context initialize

[b][color=red][size=x-large]最近刚学习是使用SSH出现下面错误,在网上搜了半天也不知道什么问题,拜托各位大虾了。 如下错误[/size][/color][/b] 2009-03-19 17:01:58,937 ERROR [main] (ContextLoader.java:203) - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hDemocratService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao': no matching editors or conversion strategy found Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao': no matching editors or conversion strategy found Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao': 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.setPropertyValue(BeanWrapperImpl.java:815) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49) 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:589) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 2009-3-19 17:01:58 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hDemocratService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao': no matching editors or conversion strategy found Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are: PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao': no matching editors or conversion strategy found Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy1] to required type [com.tzb.dao.IDemocratDao] for property 'democratDao': 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.setPropertyValue(BeanWrapperImpl.java:815) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49) 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:589) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 2009-3-19 17:01:58 org.apache.catalina.core.StandardContext start 严重: Error listenerStart 2009-3-19 17:01:58 org.apache.catalina.core.StandardContext start 严重: Context [/tzb] startup failed due to previous errors [size=x-large][color=red][b]web.xml 源代码:[/b][/color][/size] [code="java"]<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>action</servlet-name> <servlet-class> com.tzb.system.TzbServlet </servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>3</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>3</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <session-config> <session-timeout>30</session-timeout> </session-config> <!-- 该配置主要作用:在每一次请求与访问之间开启的session个数控制,要是设成true即为全过程只有一个session,否则会开启多个 --> <filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>*.do</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> [/code] [size=x-large][color=red][b]applicationContext.xml源代码:[/b][/color][/size] [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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <!-- DataBase Configuration --> <bean id="tzbDB" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://127.0.0.1:3306/tzb"></property> <property name="username" value="root"></property> <property name="password" value="root"></property> </bean> <bean id="hSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="tzbDB" /> </property> <property name="hibernateProperties"> <props> <!-- 定义hibernate的sessionFactory的属性 --> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <!-- 在这列出所有的PO映射文件XX.hbm.xml --> <value>com/tzb/vo/Democrat.hbm.xml</value> </list> </property> </bean> <!-- 声明性事务管理 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource"> <ref local="tzbDB" /> </property> </bean> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager"> <ref bean="transactionManager" /> </property> <property name="transactionAttributes"> <props> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="beanNames"> <!-- 需要添加事务管理的类在这配置,一般是业务类 --> <list> <value>hDemocratDao</value> <value>hDemocratService</value> </list> </property> <property name="interceptorNames"> <list> <value>transactionInterceptor</value> </list> </property> </bean> <!-- DAO配置 --> <bean id="hDemocratDao" class="com.tzb.dao.DemocratDao"> <property name="sessionFactory"> <ref bean="hSessionFactory" /> </property> </bean> <!-- appService配置 --> <bean id="hDemocratService" class="com.tzb.appService.democratService.DemocratService"> <property name="democratDao"> <ref bean="hDemocratDao" /> </property> </bean> <!-- action设置 --> <bean name="/democratOpt" class="com.tzb.controller.democratController.DemocratOpt"> <property name="democratService"> <ref local="hDemocratService" /> </property> </bean> </beans> [/code] [size=x-large][color=red][b]struts-config.xml 源代码:[/b][/color][/size] [code="java"] <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <data-sources /> <form-beans> <form-bean name="DemocrateForm" type="com.ctms.form.DemocrateForm"> </form-bean> </form-beans> <global-exceptions /> <global-forwards /> <action-mappings> <action name="DemocrateForm" path="/democratOpt" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" validate="false"> <forward name="democratList" path="/democrat/democratList.jsp" /> </action> </action-mappings> <controller> <set-property value="org.springframework.web.struts.DelegatingRequestProcessor" property="processorClass" /> </controller> <message-resources parameter="ApplicationResources" /> </struts-config> [/code]

SSH框架中的有关数据库的问题

我其他没有问题,就是连接数据库可能有问题,但是程序也能初始化成功,但在执行具体sql的时候,不能执行 [b]java.lang.NullPointerException at com.test.dao.BaseDaoImpl.loadObject(BaseDaoImpl.java:29) at com.test.service.impl.UserServiceImpl.selectUserByNumber(UserServiceImpl.java:38) at com.test.struts.action.UserAction.selectUserByNumber(UserAction.java:90) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441) at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.test.struts.interceptor.LoggerInterceptor.intercept(LoggerInterceptor.java:42) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at com.opensymphony.xwork2.interceptor.TimerInterceptor.invokeUnderTiming(TimerInterceptor.java:124) at com.opensymphony.xwork2.interceptor.TimerInterceptor.intercept(TimerInterceptor.java:111) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Unknown Source)[/b] 这是我的其中spring和hibernate的配置文件 [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: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/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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <!-- 开启注解处理器 --> <context:annotation-config/> <!-- 定义使用C3P0连接池的数据源 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <!-- 指定连接数据库的JDBC驱动 --> <property name="driverClass"> <value>com.mysql.jdbc.Driver</value> </property> <!-- 连接数据库所用的URL --> <property name="jdbcUrl"> <value>jdbc:mysql://localhost:3306/softtest?useUnicode=true&amp;characterEncoding=utf-8</value> </property> <!-- 连接数据库的用户名 --> <property name="user"> <value>root</value> </property> <!-- 连接数据库的密码 --> <property name="password"> <value>root</value> </property> <!-- 设置数据库连接池的最大连接数 --> <property name="maxPoolSize"> <value>20</value> </property> <!-- 设置数据库连接池的最小连接数 --> <property name="minPoolSize"> <value>2</value> </property> <!-- 设置数据库连接池的初始化连接数 --> <property name="initialPoolSize"> <value>2</value> </property> <!-- 设置数据库连接池的连接的最大空闲时间,单位为秒 --> <property name="maxIdleTime"> <value>20</value> </property> </bean> <!-- 定义Hibernate的SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 依赖注入上面定义的数据源dataSource --> <property name="dataSource" ref="dataSource"/> <!-- 注册Hibernate的ORM映射文件 --> <property name="mappingResources"> <list> <value>com/test/orm/FaultInfo.hbm.xml</value> <value>com/test/orm/ModelInfo.hbm.xml</value> <value>com/test/orm/ProjectInfo.hbm.xml</value> <value>com/test/orm/UserInfo.hbm.xml</value> <value>com/test/orm/UserModel.hbm.xml</value> <value>com/test/orm/UserFault.hbm.xml</value> <value>com/test/orm/UserProject.hbm.xml</value> <value>com/test/orm/FaultType.hbm.xml</value> <value>com/test/orm/Logger.hbm.xml</value> </list> </property> <!-- 设置Hibernate的相关属性 --> <property name="hibernateProperties"> <props> <!-- 设置Hibernate的数据库方言 --> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <!-- 设置Hibernate是否在控制台输出SQL语句,开发调试阶段通常设为true --> <prop key="show_sql">true</prop> <!-- 设置Hibernate一个提交批次中的最大SQL语句数 --> <prop key="hibernate.jdbc.batch_size">50</prop> </props> </property> </bean> <!--定义Hibernate的事务管理器HibernateTransactionManager --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <!-- 依赖注入上面定义的sessionFactory --> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 装配HibernateTemplate实例 --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <constructor-arg ref="sessionFactory"/> </bean> </beans> [/code] 这是我的数据库操作代码 [code="java"] public Object loadObject(String hql) { final String hql1 = hql; Object obj = null; try { List list = hibernateTemplate.executeFind(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { Query query = session.createQuery(hql1); return query.list(); } }); if (list.size() > 0) { obj = list.get(0); } } catch (Exception e) { e.printStackTrace(); } return obj; } [/code]

动态切换数据源不能正常切换

在开发双数据源按需切换的时候,发现不能按要求切换数据源。环境是:struts2、spring、Hibernate。源代码如下: 数据源设置类: ``` public class DataSourceSwitcher { public static final String DATA_SOURCE_MASTER = "master"; // 主库 public static final String DATA_SOURCE_SLAVE = "slave"; // 从库 private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>(); /** * 设置数据源 */ public static void setDataSource(String dbName) { contextHolder.set(dbName); } /** * 获取数据源 */ public static String getDataSource() { return (String) contextHolder.get(); } /** * 删除数据源 */ public static void removeDataSource() { contextHolder.remove(); } } ``` 动态切换类: ``` public class DynamicDataSource extends AbstractRoutingDataSource { @Override protected Object determineCurrentLookupKey() { System.out.println("切换数据源到:" + DataSourceSwitcher.getDataSource()); return DataSourceSwitcher.getDataSource(); } @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { return null; } } ``` AOP切面类: ``` @Component @Aspect @Order(0) public class DataSourceAdvice { private static Logger logger = Logger.getLogger(DataSourceAdvice.class); @Before(("@annotation(com.common.DynamicDataSourceAnnotation)")) public void before(JoinPoint point) { try { // 获取数据源 String dataSource = getDataSource(point); // 设置数据源 logger.info("设置数据源" + dataSource); DataSourceSwitcher.setDataSource(dataSource); } catch (Exception e) { logger.error("设置数据源失败..."); logger.error(StringHandleUtils.getExceptionInfo(e)); } } @After("@annotation(com.common.DynamicDataSourceAnnotation)") //后置通知 public void testAfter(JoinPoint point){ try { // 获取数据源 String dataSource = getDataSource(point); // 若数据源不是主库,则清空 if(!DataSourceSwitcher.DATA_SOURCE_MASTER.equals(dataSource)) { logger.error("删除数据源" + dataSource + "成功..."); DataSourceSwitcher.removeDataSource(); } } catch (Exception e) { logger.error("删除数据源失败..."); logger.error(StringHandleUtils.getExceptionInfo(e)); } } @SuppressWarnings("rawtypes") private String getDataSource(JoinPoint point) { String dataSource = DataSourceSwitcher.DATA_SOURCE_MASTER; try{ Class<?> className = point.getTarget().getClass(); String methodName = point.getSignature().getName(); Class[] argClass = ((MethodSignature)point.getSignature()).getParameterTypes(); Method method = className.getMethod(methodName, argClass); if (method.isAnnotationPresent(DynamicDataSourceAnnotation.class)) { DynamicDataSourceAnnotation annotation = method.getAnnotation(DynamicDataSourceAnnotation.class); dataSource = annotation.dataSource(); } }catch(Exception e) { logger.error("获取数据源失败..."); logger.error(StringHandleUtils.getExceptionInfo(e)); } return dataSource; } } ``` 注解类: ``` @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface DynamicDataSourceAnnotation { String dataSource() default DataSourceSwitcher.DATA_SOURCE_MASTER; } ``` 配置文件: ``` <!-- master --> <bean id="master" class="com.common.DataSource"> <property name="driver" value="${master.datasource.driverClassName}" /> <property name="driverUrl" value="${master.datasource.url}" /> <property name="user" value="${master.datasource.username}"/> <property name="password" value="${master.datasource.password}"/> <property name="alias" value="master" /> </bean> <!-- slave --> <bean id="slave" class="com.common.DataSource"> <property name="driver" value="${slave.datasource.driverClassName}" /> <property name="driverUrl" value="${slave.datasource.url}" /> <property name="user" value="${slave.datasource.username}"/> <property name="password" value="${slave.datasource.password}"/> <property name="alias" value="slave" /> </bean> <!-- 配置动态切换数据源 --> <bean id="dataSource" class="com.common.DynamicDataSource"> <property name="defaultTargetDataSource" ref="master"></property> <property name="targetDataSources"> <map key-type="java.lang.Object"> <entry value-ref="master" key="master"></entry> <entry value-ref="slave" key="slave"></entry> </map> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> </props> </property> <property name="packagesToScan" value="com.common.pojo"/> </bean> <!-- 定义事务管理器(声明式的事务) --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <aop:aspectj-autoproxy proxy-target-class="true" /> <tx:annotation-driven transaction-manager="transactionManager" /> ``` 使用: Action层: ``` @Action(name = "common") @Component public class CommonAction extends ActionSupport{ @Autowired private CommonService service; public String queryInfo() { List<TradeInfo> list = service.queryInfo(); for(TradeInfo ti : list) { System.out.println("service.queryInfo():" + ti.getName()); } System.out.println("================================"); List<TradeInfo> list2 = service.queryInfo2(); for(TradeInfo ti : list2) { System.out.println("service.queryInfo2():" + ti.getName()); } return "index"; } } ``` Service层: ``` @Service @Transactional(rollbackFor = Exception.class) public class CommonService { @Autowired private CommonDAO commonDAO; @SuppressWarnings("unchecked") @Override @DynamicDataSourceAnnotation(dataSource = DataSourceSwitcher.DATA_SOURCE_MASTER) public List<TradeInfo> queryInfo() throws SystemException { try { String sql = "FROM TradeInfo"; return this.commonDAO.find(sql); } catch (Exception e) { } } @SuppressWarnings("unchecked") @Override @DynamicDataSourceAnnotation(dataSource = DataSourceSwitcher.DATA_SOURCE_SLAVE) public List<TradeInfo> queryInfo2() throws SystemException { try { String sql = "FROM TradeInfo"; return this.commonDAO.find(sql); } catch (Exception e) { } } } ``` Dao层: ``` @Repository public class CommonDao extends HibernateDaoSupport { public List find(String sql) throws SystemException { try { return getHibernateTemplate().find(sql); } catch (DataAccessException e) { } catch (HibernateException e) { } catch (SQLException e) { } return null; } } ``` 测试输出结果: ``` 设置数据源master 切换数据源到:master 删除数据源master成功... service.queryInfo():主数据源 ================================ 设置数据源slave 切换数据源到:slave service.queryInfo()2:主数据源 ``` 从输出信息可以看出数据源并没有成功切换。queryInfo()走的是主数据源;queryInfo()2走的也是主数据源。 调试结果是:第一个方法可以正常切换数据源,第一个方法之后的方法都无法正常切换,获取的连接是第一个方法的连接。 而在Action中用Main方法: ``` public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); CommonAction = (CommonAction ) ctx.getBean("commonAction"); c.queryInfo(); ) ``` 输出结果: ``` 设置数据源master 切换数据源到:master 切换数据源到:master 删除数据源master成功... service.queryInfo():主数据源 ================================ 设置数据源slave 切换数据源到:slave 切换数据源到:slave service.queryInfo()2:从数据源 ``` 从输出信息可以看出数据源按照预期正常切换了。 请问出现这种问题有哪些可能因素影响呢?

老板的奇怪想法

最近公司老板有一个想法,请大家一起讨论一下 老板想用SSH架构做基盘,在这个基础上封装一下.现在有这么一个功能 以前struts是这样做验证的,首先就是在struts.xml里配一下 <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validation.xml" /> </plug-in> 然后就是validation.xml的内容,如下 <form-validation> <formset> <form name="/Sample"> <field property="dwgNo" depends="required"> <arg0 key="input.dwgNo" /> </field> </form> </formset> </form-validation> 老板想这样多麻烦,他想把这个validation.xml的内容放到数据库里去,表的结构如下图 [img]/upload/attachment/93237/42e00b8f-0f33-39bd-ae5a-73cde3512153.bmp[/img] 功能还是要和以前STRUTS一样,表单提交里要先验证一下,但是这个validation.xml文件是没有的 要到数据库里去取。 这样的话就有多种实现,要么就改改org.apache.struts.validator.ValidatorPlugIn这个类, 要么就写这和这个类一样功能的类,但它原来是读validation.xml文件,现在是读数据库。 大家能否给点实现方式,最好是能贴上代码,谢谢了 [b]问题补充:[/b] 没办法,做员工的只能听老板的话,要么我就写一个类似于ValidatorPlugIn这样的类吧,代替原来的STRUTS验证,用SPRING的AOP可行吗? [b]问题补充:[/b] 我打算改一下ValidatorPlugin相关类的源代码,我用的是struts2.1.6,我下载了源代码,我把它放到我的工程里面,但是现在报这个错: 2009-04-14 14:13:30,421 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/sshdemo2]]-[ERROR] Exception starting filter struts2 Unable to load configuration. - bean - jar:file:/E:/apache-tomcat-5.5.17/webapps/sshdemo2/WEB-INF/lib/struts2-core-2.1.6.jar!/struts-default.xml:29:72 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:223) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:304) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:77) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3600) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4193) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) at org.apache.catalina.startup.Catalina.start(Catalina.java:551) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/E:/apache-tomcat-5.5.17/webapps/sshdemo2/WEB-INF/lib/struts2-core-2.1.6.jar!/struts-default.xml:29:72 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:222) at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:165) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) ... 31 more Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - file:/E:/apache-tomcat-5.5.17/webapps/sshdemo2/WEB-INF/classes/struts-default.xml:29:72 - bean - jar:file:/E:/apache-tomcat-5.5.17/webapps/sshdemo2/WEB-INF/lib/struts2-core-2.1.6.jar!/struts-default.xml:29:72 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:206) ... 34 more 说我找不到struts-default.xml这个文件,确实我下的源码里是没有这个文件,但我把这个文件放到SRC目录下了啊,为什么会报错????? [b]问题补充:[/b] 我知道啊,我们公司用的是STRUTS2.1.6,这里面也有像1.X版本里的验证框架吧, 帮我看看吧,我现在有上面的异常 我把struts-default.xml放到WEB-INF/下面之后又报下面的异常 2009-04-14 14:30:44,453 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/sshdemo2]]-[ERROR] Exception starting filter struts2 java.lang.RuntimeException: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='struts.objectFactory.spring.autoWire'] in public org.apache.struts2.spring.StrutsSpringObjectFactory(java.lang.String,java.lang.String,java.lang.String,javax.servlet.ServletContext). at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:132) at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51) at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:507) at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:517) at com.opensymphony.xwork2.inject.ContainerImpl$9.call(ContainerImpl.java:548) at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:574) at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:546) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:182) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:223) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:304) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:77) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3600) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4193) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021) at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) at org.apache.catalina.core.StandardService.start(StandardService.java:450) at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) at org.apache.catalina.startup.Catalina.start(Catalina.java:551) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) Caused by: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='struts.objectFactory.spring.autoWire'] in public org.apache.struts2.spring.StrutsSpringObjectFactory(java.lang.String,java.lang.String,java.lang.String,javax.servlet.ServletContext). at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:495) at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:532) at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:581) at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:530) at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32) at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130) ... 39 more Caused by: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='struts.objectFactory.spring.autoWire'] in public org.apache.struts2.spring.StrutsSpringObjectFactory(java.lang.String,java.lang.String,java.lang.String,javax.servlet.ServletContext). at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.<init>(ContainerImpl.java:345) at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:305) at com.opensymphony.xwork2.inject.ContainerImpl$5.create(ContainerImpl.java:304) at com.opensymphony.xwork2.inject.util.ReferenceCache$CallableCreate.call(ReferenceCache.java:150) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at com.opensymphony.xwork2.inject.util.ReferenceCache.internalCreate(ReferenceCache.java:76) at com.opensymphony.xwork2.inject.util.ReferenceCache.get(ReferenceCache.java:116) at com.opensymphony.xwork2.inject.ContainerImpl.getConstructor(ContainerImpl.java:594) at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:491) ... 44 more Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=java.lang.String, name='struts.objectFactory.spring.autoWire'] in public org.apache.struts2.spring.StrutsSpringObjectFactory(java.lang.String,java.lang.String,java.lang.String,javax.servlet.ServletContext). at com.opensymphony.xwork2.inject.ContainerImpl.createParameterInjector(ContainerImpl.java:235) at com.opensymphony.xwork2.inject.ContainerImpl.getParametersInjectors(ContainerImpl.java:225) at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.constructParameterInjector(ContainerImpl.java:353) at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.<init>(ContainerImpl.java:337) ... 53 more 这是为什么啊? [b]问题补充:[/b] 王者之剑你好 这个问题怎么解决啊 我肯定少了什么文件没加上去,但我不知道 我就是把STRUTS1.2.6的源码放到我的工程里了,然后删掉原来的struts2-core-2.1.6.jar这个包. [b]问题补充:[/b] STRUTS2.1.6源码,上面写错了 [b]问题补充:[/b] 对了还有,没替换这个包之前,我的项目是能跑通的 我的JAR包肯定都有的 只不过源码里没有struts-default.xml这个文件 我还少什么没加上?加在哪儿? [b]问题补充:[/b] 嗯,改源码确实很难. STRUTS2.1.6太复杂了,STRUTS1.3的话还可以考虑 大家说说,有什么解决方案吗? 给提供一下 [b]问题补充:[/b] 不会吧,我什么时候说过两个框架要一起用 哎~ 能不能提点好的意见,真服了你 我打算用拦截器去做 在ACTION的方法调用前做一把处理 [b]问题补充:[/b] 兄弟,我没说我要一起用啊 大哥 我说的是STRUTS1.3的话,改STRUTS源码比较容易 但我现在用的是STRUTS2.1.6啊 我用拦截器差不多实现这个功能了 [b]问题补充:[/b] 嗯,现在你知道了 不过,你能不能提点好的建议啥的啊 不要只是路过啊

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

Linux命令学习神器!命令看不懂直接给你解释!

大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢? 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

史上最全的 python 基础知识汇总篇,没有比这再全面的了,建议收藏

网友们有福了,小编终于把基础篇的内容全部涉略了一遍,这是一篇关于基础知识的汇总的文章,请朋友们收下,不用客气,不过文章篇幅肯能会有点长,耐心阅读吧爬虫(七十)多进程multiproces...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

新一代神器STM32CubeMonitor介绍、下载、安装和使用教程

关注、星标公众号,不错过精彩内容作者:黄工公众号:strongerHuang最近ST官网悄悄新上线了一款比较强大的工具:STM32CubeMonitor V1.0.0。经过我研究和使用之...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

大学一路走来,学习互联网全靠这几个网站,最终拿下了一把offer

大佬原来都是这样炼成的

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

程序员必知的 89 个操作系统核心概念

操作系统(Operating System,OS):是管理计算机硬件与软件资源的系统软件,同时也是计算机系统的内核与基石。操作系统需要处理管理与配置内存、决定系统资源供需的优先次序、控制输入与输出设备、操作网络与管理文件系统等基本事务。操作系统也提供一个让用户与系统交互的操作界面。 shell:它是一个程序,可从键盘获取命令并将其提供给操作系统以执行。 在过去,它是类似 Unix 的系统上...

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

立即提问
相关内容推荐