整合ssh,出现问题,使用spring AOP的环绕通知拦截页面访问action,在改变返回字符串时,出现异常

环绕通知前
这是前置通知one!请求目标方法名:findAll
这是action的findAll方法的执行。。。
在DAO中查找商品的findAll方法。。。。
Hibernate:
select
this_.pid as pid1_0_0_,
this_.pname as pname2_0_0_,
this_.price as price3_0_0_
from
product this_
在DAO中返回
环绕通知后
八月 06, 2019 2:10:44 上午 org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler error
严重: Exception occurred during processing request: Invalid action class configuration that references an unknown class named [productAction]
java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [productAction]
at org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:99)
at org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:404)
at org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:286)
at com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:85)
at com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:366)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:276)
at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:168)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:140)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:575)
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:151)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: productAction
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152)
at org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:97)
... 80 more

2个回答

已经解决,晚上眼神不太好,修改struts配置的action时,修改错了

是的,异常也定位是 Invalid action class configuration that references an unknown class named [productAction] 这里没有找到映射路径。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
关于spring4.X的aop配置问题
例子配置文件 ``` <!-- 配置事务通知属性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <!-- 定义事务传播属性 --> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="edit*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="add*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="new*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="set*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="remove*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="change*" propagation="REQUIRED" rollback-for="Exception"/> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="load*" propagation="REQUIRED" read-only="true" /> <tx:method name="*" propagation="REQUIRED" read-only="true" /> </tx:attributes> </tx:advice> <!-- 配置事务切面 --> <aop:config> <aop:pointcut id="serviceOperation" expression="execution(* com.cbgmcs.service..*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" /> </aop:config> ``` 在上面的例子中,这个事务切面指的是对com.cbgmcs.service类中的被txAdvice中声明的方法做拦截约束吗? 如果是这样的话,service层不是应该是实现业务逻辑的吗?上面那个get, find, insert等方法不都是dao层的方法来的吗?应该不可能在service实现上面的方法吧。 我看网上很多例子都是约束在service层的,难道service层是实现数据库增删查改的? 根据我的理解,假设这个是一个userService的话,里面的方法应该是login()之类的吧,而不get, find, insert等方法吧。 求指导。
S2SH集成中使用AOP后查询结果为NULL?。。请教高手解答一下
做SSH集成,用得是spring的声明式事务和hibernate做的集成。 以下是spring配置文件中关于AOP的配置: <!-- 配置aop拦截声明类 --> <bean id = "myAop" class="com.acc.aop.MyAop"></bean> <aop:config> <aop:pointcut expression="execution(* com.acc.service.*.*(..))" id="pointCut"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="pointCut"/> <!-- 配置切面 --> <aop:aspect id="aspect" ref="myAop"> <aop:after method="after" pointcut-ref="pointCut"/> <aop:after-returning method="afterReturning" pointcut-ref="pointCut"/> <!--环绕 --> <aop:around method="arroundAdvice" pointcut-ref="pointCut"/> <aop:before method="beforeAdvice" pointcut-ref="pointCut"/> </aop:aspect> </aop:config> 之后是从Dao 层 ---》service层----》action层逐层注入的,在action中查询结果集,调用注入在action层中的service层接口,执行数据查询操作时,查询的结果为NUll!!!! 我试了一下把上面配置文件中的`<aop:aspect id="aspect" ref="myAop"></sop:aspect>`标签中配置的环绕通知配置项注释掉后,可以查询出结果集. 一下是自定义的aop类中的环绕方法: public void arroundAdvice(ProceedingJoinPoint pjp){ System.out.println("环绕通知"); try { pjp.proceed(); } catch (Throwable e) { e.printStackTrace(); } } 为什么注释了配置文件中有关于环绕通知的配置后就可以查询出结果集了?? <!--环绕 --> <aop:around method="arroundAdvice" pointcut-ref="pointCut"/> 不懂了,恳请各位帮忙解决!
spring+hibernate配置多数据源动态切换,java实体如何和各个数据库实例映射?
我的一个javaweb项目,需要用到多个数据源,都是oracle实例,我用spring配置了数据源的动态切换。使用AOP在service层做拦截,然后用注解DataSource来标示所要选择的数据源。现在我有一个问题,就是我用数据库操作时,hibernate是面向对象的,我该如何将不同的java实体映射到不同的数据源上(不同数据库表结构不同)。比如一个product包中的java实体映射到数据库1,cart包中的实体映射到数据库2。如何做到呢?
最简单的aop实例,总是报错,求大神指点
package cn.itcast.service; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; //指明这个类为一个切面 @Aspect public class MyInterceptor { // 切入点,拦截方法(执行( //*-->返回值的类型 //包名 //..-->对子包以下的类也要进行拦截 //*-->子包以下的所有类 //*-->所有的方法 //(..-->方法的参数任意数量))) //对业务bean里面的所有方法进行拦截 @Pointcut("execution (* cn.itcast.service.bean.PersonServiceBean.*(..))") private void anyMethod() {}//声明一个切入点 /*拦截到类底下的所有方法-->方法执行前执行doAccessCheck() * -->执行被拦截到的方法*/ @Before("anyMethod()")//执行业务方法前执行 public void doAccessCheck(String name) { System.out.println("前置通知:"+ name); } } ``` package cn.itcast.service.bean; import cn.itcast.service.PersonService; public class PersonServiceBean implements PersonService{ @Override public void save(String name) { System.out.println("save()___"); } @Override public void update(String name, Integer id) { System.out.println("update()___"); } @Override public String getPersonName(Integer id) { System.out.println("getPersonName()___"); return "xxx"; } } ``` <?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" 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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <!-- 切面编程 --> <aop:aspectj-autoproxy/> <!-- 切面类交给spring进行管理 --> <bean id="myInterceptor" class="cn.itcast.service.MyInterceptor"/> <bean id="personService" class="cn.itcast.service.bean.PersonServiceBean"></bean> </beans> package junit.test; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import cn.itcast.service.PersonService; import cn.itcast.service.bean.PersonServiceBean; public class SpringAOPTest { @Test public void interceptorTest(){ ApplicationContext cxt = new ClassPathXmlApplicationContext("application.xml"); PersonService personService = (PersonService)cxt.getBean("personService"); personService.save("xx"); } } ``` package cn.itcast.service; public interface PersonService { public void save(String name) ; public void update(String name,Integer id) ; public String getPersonName(Integer id) ; } ``` org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService' defined in class path resource [application.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at junit.test.SpringAOPTest.interceptorTest(SpringAOPTest.java:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:292) 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.IllegalArgumentException: error at ::0 formal unbound in pointcut at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317) at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:206) at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:193) at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:174) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:195) at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:250) at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:284) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:113) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:85) at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362) at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:325) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:361) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1344) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) ... 37 more 求大神指点
ssh实现数据透明加解密
最近客户要求我们需要做个针对用户敏感信息进行加密存储解密显示的功能,我们系统是SSH架构,spring2.5,hibernate3.0. 且hibernate是在Spring中创建代理的, 原本打算用SpringAOP来切入业务层的查询保存来进行加密解密,后来了解到AOP需要一个Service一个service的去针对才符合要求后,就放弃了。应为系统中存在子类 实现父类的service,无法切子类自己的方法。 后来打算在DAO层进行hibernate的监听与拦截,通过实现PostLoadEventListener,对查询出来的数据进行解密,但是对手写的HQ查询的方法无法监听到。而且hibernate 有实例化对象当前与历史做对比若发生变化就保存这个功能,只能清除或者在会话结束后调一下加密。拦截器就尴尬了我只能拦截到Onsave方法,对update就拦截不到了 实现过saveorupdate监听后,确实监听到了,但是系统中调用的saveorupdate方法没有存入数据库。看来此方法也行不通。 小弟初来乍到,对框架也不算熟悉,最近才算研究系统框架,求大神指导一下以上两个方案是否有哪些不足,或贵项目有类似功能都用的什么方式解决的,谢谢了。
SSH整合过程中:service老是注入失败?
action对象是用struts2产生的,但是service老是注入失败,其他的dao注入正常,在action中通过getbean的方式可以正常获得service beans.xml如下: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/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"> <context:annotation-config /> <!-- 分散配置(配置配置文件的位置) --> <context:property-placeholder location= "classpath:jdbc.properties"/> <!-- 生成实例对象要扫描的包,扫描该包,将该包下的注解@Component的类实例化 --> <context:component-scan base-package="com.slg.surveypark.dao.impl,com.slg.surveypark.service.impl,com.slg.surveypark.struts2.action" /> <!-- 配置数据源 --> <bean id="dataSource" destroy-method="close" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClassName}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="maxPoolSize" value="${c3p0.pool.size.max}"/> <property name="minPoolSize" value="${c3p0.pool.size.min}"/> <property name="initialPoolSize" value="${c3p0.pool.size.ini}"/> <property name="acquireIncrement" value="${c3p0.pool.size.increment}"/> </bean> <!--本地会话工程(spring整合 hibernate配置) --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 扫描一下包内的实体类,有@Entity注解与数据库形成映射 --> <property name="packagesToScan"> <list> <value>com.slg.surveypark.model</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <!-- hibernate.hbm2ddl.auto 当为update时根据java对象生成数据库里的表 --> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <aop:config> <aop:pointcut id="bussinessService" expression="execution(* *..*Service.*(..))" /> <aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <!-- 写操作 --> <tx:method name="save*" propagation="REQUIRED" isolation="DEFAULT"/> <tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT"/> <tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT"/> <tx:method name="batch*" propagation="REQUIRED" isolation="DEFAULT"/> <!-- 读操作 --> <tx:method name="load*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/> <tx:method name="get*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/> <tx:method name="find*" propagation="REQUIRED" isolation="DEFAULT" read-only="true"/> <tx:method name="*" propagation="REQUIRED" isolation="DEFAULT" /> </tx:attributes> </tx:advice> </beans> ``` 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.ui.theme" value="simple" /> <!-- 开发模式 --> <constant name="struts.devMode" value="true" /> <package name="surveypark" namespace="/" extends="struts-default"> <action name="RegAction_*" class="com.slg.surveypark.struts2.action.RegAction" method="{1}"> <result name="regPage">/reg.jsp</result> <result name="input">/reg.jsp</result> <result name="success">/index.jsp</result> </action> </package> </struts> ``` action类 ``` package com.slg.surveypark.struts2.action; import javax.annotation.Resource; import org.apache.struts2.interceptor.validation.SkipValidation; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Scope; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.stereotype.Component; import com.slg.surveypark.model.User; import com.slg.surveypark.service.UserService; import com.slg.surveypark.service.impl.UserServiceImpl; import com.slg.surveypark.util.ValidateUtil; //@Component("regaction") //@Scope("prototype") //@Controller public class RegAction extends BaseAction<User> { /** * */ private static final long serialVersionUID = 1L; private User model = new User(); private String confirmPassword; public String getConfirmPassword() { return confirmPassword; } public void setConfirmPassword(String confirmPassword) { this.confirmPassword = confirmPassword; } protected UserService userService; public UserService getUserService() { return userService; } @Resource(name="userService") public void setUserService(UserService userService) { this.userService = userService; } @Override public User getModel() { // TODO Auto-generated method stub return model; } /** * * 这里添加了注解 @SkipValidation 所以会跳过默认的拦截器函数validate() */ @SkipValidation public String toRegPage(){ return "regPage"; } public String doReg(){ userService.saveEntity(model); return SUCCESS; } /** * struts2的默认验证拦截器,所有的action执行前都会执行此函数,除非有跳过注解,如果验证过程有有问题,则 * 终端action的执行过程,返回到struts2配置的“input”指向的页面 */ public void validate(){ if(!ValidateUtil.isValid(model.getEmail())){ addFieldError("email", "email是必填项!"); } if(!ValidateUtil.isValid(model.getNickName())){ addFieldError("nickname", "nickname是必填项!"); } if(!ValidateUtil.isValid(model.getPassword())){ addFieldError("password", "password是必填项!"); } if(hasErrors()){ return ; } if(!model.getPassword().equals(confirmPassword)){ addFieldError("password", "密码不一致!"); return ; } //通过getBean可以获得service // ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml"); // userService = (UserService)ctx.getBean("userService"); System.out.println(userService); if(userService.isRegisted(model.getEmail())){ addFieldError("email", "email已占用!"); return; } } } ``` service类 ``` package com.slg.surveypark.service.impl; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import com.slg.surveypark.dao.BaseDao; import com.slg.surveypark.model.User; import com.slg.surveypark.service.UserService; import com.slg.surveypark.util.ValidateUtil; @Component("userService") public class UserServiceImpl extends BaseServiceImpl<User> implements UserService { @Resource(name="userDao") public void setDao(BaseDao<User> dao) { super.setDao(dao); } /** * 判断email是否被注册过 */ public boolean isRegisted(String email){ String hql = "select email from User where email =?"; List<User> users = this.findEntityByHQL(hql, email); return ValidateUtil.isValid(users); } } ``` 求指教
初学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] 请问这是为什么呢?
关于struts2+spring2+hibernate3的问题
信息: Using DataSource [com.mchange.v2.c3p0.ComboPooledDataSource@e64686[ acquir eIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, allUsers -> [root], autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAc quireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mc hange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 15ad5c6, descripti on -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> e64686, idleConnect ionTestPeriod -> 900, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost:33 06/mysql?useUnicode=true&characterEncoding=UTF-8, maxIdleTime -> 600, maxPoolSiz e -> 50, maxStatements -> 100, maxStatementsPerConnection -> 0, minPoolSize -> 2 , numHelperThreads -> 10, preferredTestQuery -> null, properties -> {user=****** , password=******}, propertyCycle -> 300, testConnectionOnCheckin -> false, test ConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ]] of H ibernate SessionFactory for HibernateTransactionManager 2010-11-15 9:29:05 org.springframework.web.context.ContextLoader initWebApplicat ionContext 信息: Root WebApplicationContext: initialization completed in 4119 ms 2010-11-15 9:29:06 org.apache.catalina.core.StandardContext start [color=red]严重: Error listenerStart 2010-11-15 9:29:06 org.apache.catalina.core.StandardContext start 严重: Context [/ssh] startup failed due to previous errors 2010-11-15 9:29:06 org.springframework.context.support.AbstractApplicationContex t doClose[/color] 信息: Closing org.springframework.web.context.support.XmlWebApplicationContext@7 6e369: display name [Root WebApplicationContext]; startup date [Mon Nov 15 09:29 :01 CST 2010]; root of context hierarchy 2010-11-15 9:29:06 org.springframework.beans.factory.support.DefaultSingletonBea nRegistry destroySingletons 信息: Destroying singletons in org.springframework.beans.factory.support.Default ListableBeanFactory@4c4975: defining beans [propertyConfigurer,dataSource,sessio nFactory,transactionManager,transactionInterceptor,org.springframework.aop.frame work.autoproxy.BeanNameAutoProxyCreator,LoginAction,genericDao,userDao,userServi ce]; root of factory hierarchy 2010-11-15 9:29:06 org.springframework.orm.hibernate3.AbstractSessionFactoryBean destroy 信息: Closing Hibernate SessionFactory 2010-11-15 9:29:07 org.springframework.web.servlet.FrameworkServlet initServletB ean 信息: FrameworkServlet 'dispatcher': initialization started 2010-11-15 9:29:07 org.springframework.context.support.AbstractApplicationContex t prepareRefresh 信息: Refreshing org.springframework.web.context.support.XmlWebApplicationContex 没集成hibernate3时,struts2+spring2还是好的,不知道是不是包冲突了,但我加的包的版本都是合适的呀 struts2:struts-2.0.14 spring2:spring-framework-2.0.8 hibernate3:hibernate-distribution-3.6.0.Final 希望大大们讲解一下,问题是哪里? applicationContext-hibernate.xml如下: [code="xml"]<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <!-- <value>WEB-INF/mail.properties</value>--> <value>WEB-INF/jdbc.properties</value> <!-- <value>WEB-INF/oscache.properties</value>--> </list> </property> </bean> <!-- MailSender used by EmailAdvice --> <!-- <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="${mail.host}"/> </bean> --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" dependency-check="none"> <property name="driverClass"> <value>${datasource.driverClassName}</value> </property> <property name="jdbcUrl"> <value>${datasource.url}</value> </property> <property name="user"> <value>${datasource.username}</value> </property> <property name="password"> <value>${datasource.password}</value> </property> <property name="acquireIncrement"> <value>${c3p0.acquireIncrement}</value> </property> <property name="initialPoolSize"> <value>${c3p0.initialPoolSize}</value> </property> <property name="minPoolSize"> <value>${c3p0.minPoolSize}</value> </property> <property name="maxPoolSize"> <value>${c3p0.maxPoolSize}</value> </property> <property name="maxIdleTime"> <value>${c3p0.maxIdleTime}</value> </property> <property name="idleConnectionTestPeriod"> <value>${c3p0.idleConnectionTestPeriod}</value> </property> <property name="maxStatements"> <value>${c3p0.maxStatements}</value> </property> <property name="numHelperThreads"> <value>${c3p0.numHelperThreads}</value> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="mappingResources"> <list> <value>cn/com/aaCompany/app/biz/hibernate/User.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop> </props> </property> </bean> <!-- 配置事务管理器bean,使用 HibernateTransactionManager事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <!-- 为事务管理器注入sessionFactory" --> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 配置事务拦截器Bean --> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <!-- 为事务拦截器bean注入一个事物管理器 --> <property name="transactionManager" ref="transactionManager"></property> <property name="transactionAttributes"> <!-- 定义事务传播属性 --> <props> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="change*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <!-- 定义BeanNameAutoProxyCreator --> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <!-- 指定满足哪些bean自动生成业务代理 --> <property name="beanNames"> <!-- 需要自动创建事务代理的bean --> <list> <value>userService</value>[/code] </list> <!-- 其它需要自动创建事务代理的bean --> </property> <property name="interceptorNames"> <list> <value>transactionInterceptor</value> <!-- 可增加其它的interceptor --> </list> </property> </bean> </beans>
spring配置文件怎么也找不出是哪错了,虽然提示信息明显
这是提示的错误信息: 大致意思是缺少id为sessionFactory的元素,但我明明定义了呀,真得找不出是哪错了…… ································································································· 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Line 97 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: An element with the identifier "sessionFacotry" must appear in the document. org.xml.sax.SAXParseException: An element with the identifier "sessionFacotry" must appear in the document. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:222) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:173) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:148) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:128) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:144) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:126) at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:89) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:262) at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:139) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184) 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.startup.HostConfig.checkResources(HostConfig.java:1116) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1214) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) at java.lang.Thread.run(Unknown Source) 2009-7-5 23:31:42 org.apache.catalina.core.StandardContext start 严重: Error listenerStart 2009-7-5 23:31:42 org.apache.catalina.core.StandardContext start 严重: Context [/SSH2] startup failed due to previous errors 2009-7-5 23:31:42 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext ·································································································· 这是我的spring配置文件: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <!-- 配置数据源与事务 --> <bean id = "dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>oracle.jdbc.driver.OracleDriver</value> </property> <property name="url"> <value>jdbc:oracle:thin:@localhost:1521:ora92</value> </property> <property name="username" value="asfd" /> <property name="password" value="sadf" /> </bean> <!-- 配置Hibernate --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="mappingResources"> <list> <value>hibernate/bean/Usertable.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.OracleDialect</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 --> <!-- usertableDAO" --> <bean id="userDAO" class="hibernate.dao.StudentDAO"> <property name="sessionFactory"> <ref local="sessionFacotry"/> </property> </bean> <!-- 配置DAO事务 --> <bean id="useDAOProxy" class="org.springframework.transaction.interceptor.TransacionProxyBean"> <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> <!-- 配置拦截器 --> <bean name="logger" class="com.demo.spring.aop.LoggingInterceptor"></bean> <!-- 配置拦截器代理 --> <bean name="logginAutoProxy" 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> <!-- Action配置 --> <bean name="Login" class="strtus2.actions.LoginAction"> <property name="userDAO"> <ref local="userDAO" /> </property> </bean> <bean name="Register" class="struts2.actions.Register"> <property name="userDAO"> <ref local="userDAO" /> </property> </bean> </beans> ································································································ 有时间帮一下忙,真得被它搞死了 谢谢了
UrlReWriterFilter伪静态一直报异常,求助
这是异常信息: ``` 13:23:15,510 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0' 04-Nov-2017 13:23:15.731 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file 04-Nov-2017 13:23:15.731 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [/generalize] startup failed due to previous errors 13:23:15,768 INFO RMI TCP Connection(2)-127.0.0.1 support.XmlWebApplicationContext:987 - Closing Root WebApplicationContext: startup date [Sat Nov 04 13:23:07 CST 2017]; root of context hierarchy 13:23:15,769 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DefaultListableBeanFactory:251 - Returning cached instance of singleton bean 'lifecycleProcessor' 13:23:15,769 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DefaultListableBeanFactory:512 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2865c2f8: defining beans [baseDaoImpl,tableDaoImpl,tableServiceImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,sessionFactory,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0]; root of factory hierarchy 13:23:15,770 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DefaultListableBeanFactory:568 - Retrieved dependent beans for bean 'sessionFactory': [baseDaoImpl, tableDaoImpl, transactionManager] 13:23:15,770 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DefaultListableBeanFactory:568 - Retrieved dependent beans for bean 'tableDaoImpl': [tableServiceImpl] 13:23:15,770 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DefaultListableBeanFactory:568 - Retrieved dependent beans for bean 'transactionManager': [txAdvice] 13:23:15,771 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DefaultListableBeanFactory:568 - Retrieved dependent beans for bean '(inner bean)#432df6b2': [txAdvice] 13:23:15,771 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DisposableBeanAdapter:259 - Invoking destroy() on bean with name 'sessionFactory' 13:23:15,772 DEBUG RMI TCP Connection(2)-127.0.0.1 support.DisposableBeanAdapter:337 - Invoking destroy method 'close' on bean with name 'dataSource' 04-Nov-2017 13:23:15.781 警告 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [generalize] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. [2017-11-04 01:23:15,813] Artifact Generalize:war exploded: Error during artifact deployment. See server log for details. ``` web.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <!-- 通过ServletContext初始化参数指定Spring配置文件位置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 配置Spring ContextListener --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配置Spring字符编码过滤器 --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>*.action</url-pattern> <url-pattern>*.jsp</url-pattern> </filter-mapping> <!-- UrlReWriterFilter --> <filter> <filter-name>UrlReWriterFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> </filter> <filter-mapping> <!-- 这里的名字要对应上UrlReWriterFilter --> <filter-name>UrlReWriterFilter</filter-name> <!-- 这里是选择过滤掉全部的Url --> <url-pattern>/*</url-pattern> <!-- 主要说明该拦截器拦截的请求包括客户端的请求和从服务器端forward的请求 --> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <!-- 配置struts核心过滤器 --> <filter> <filter-name>struts</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts</filter-name> <url-pattern>*.action</url-pattern> <url-pattern>*.jsp</url-pattern> </filter-mapping> </web-app> ``` 还请大神们帮忙看看,问题出在哪里了,不在web.xml中配置UrlReWriterFilter就没有问题,一配置就会有这个警告
老板的奇怪想法
最近公司老板有一个想法,请大家一起讨论一下 老板想用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岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
【JSON解析】浅谈JSONObject的使用
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
世界上有哪些代码量很少,但很牛逼很经典的算法或项目案例?
点击上方蓝字设为星标下面开始今天的学习~今天分享四个代码量很少,但很牛逼很经典的算法或项目案例。1、no code 项目地址:https://github.com/kelseyhight...
Python全栈 Linux基础之3.Linux常用命令
Linux对文件(包括目录)有很多常用命令,可以加快开发效率:ls是列出当前目录下的文件列表,选项有-a、-l、-h,还可以使用通配符;c功能是跳转目录,可以使用相对路径和绝对路径;mkdir命令创建一个新的目录,有-p选项,rm删除文件或目录,有-f、-r选项;cp用于复制文件,有-i、-r选项,tree命令可以将目录结构显示出来(树状显示),有-d选项,mv用来移动文件/目录,有-i选项;cat查看文件内容,more分屏显示文件内容,grep搜索内容;>、>>将执行结果重定向到一个文件;|用于管道输出。
立即提问