Spring Question

问题描述

Errorinformation不知道哪里配置错了。java.lang.NullPointerExceptionatjflying.common.action.TreeExtAction.treeExtId(TreeExtAction.java:31)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atcom.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)atcom.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)atcom.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)atorg.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)atcom.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atcom.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)atcom.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)atorg.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)atorg.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)atorg.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)atorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)atorg.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)atorg.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)atorg.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)atjava.lang.Thread.run(Thread.java:619)我在Application.xml配置是<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsd"><beanid="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><propertyname="configLocation"value="classpath:hibernate.cfg.xml"></property></bean><!--事务管理器--><beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><propertyname="sessionFactory"><reflocal="sessionFactory"/></property></bean></beans>用注解的方式注解@Autowired到Struts2的Action里但service里的定义在调试是为null@Controller("treeExtAction")@Scope("prototype")publicclassTreeExtActionextendsActionSupport{@AutowiredprivateITreeExtiTreeExt;privateTreeExttreeExt;//实体publicStringtreeExtId(){try{System.out.println("Test");treeExt=iTreeExt.getTreeExt(2);//在这里,ITreeExt在调试步入到这里时,iTreeExt为null然后被catch捕获treeExt.setTrUniqunecode("TreeExt");System.out.println("Mark");}catch(Exceptione){e.printStackTrace();}return"treeext";}publicTreeExtgetTreeExt(){returntreeExt;}publicvoidsetTreeExt(TreeExttreeExt){this.treeExt=treeExt;}}=========================================================service@ServicepublicclassTreeExtImplsimplementsITreeExt{@AutowiredprivateITreeExtDaotreeExtDao;/*privateSessionFactorysessionFactory;publicvoidsetSessionFactory(SessionFactorysessionFactory){this.sessionFactory=sessionFactory;}*/publicvoidaddTreeExt(TreeExttreeExt){this.treeExtDao.addTreeExt(treeExt);}publicvoiddelTreeExt(inttreeExtId){this.treeExtDao.delTreeExt(treeExtId);}publicPagergetAllTreeExt(){returnnull;}publicTreeExtgetTreeExt(inttreeExtid){returnthis.treeExtDao.getTreeExt(treeExtid);}publicvoidupdateTreeExt(TreeExttreeExt){this.treeExtDao.updateTreeExt(treeExt);}}=============================================================dao@RepositorypublicclassTreeExtDaoImplsimplementsITreeExtDao{@AutowiredprivateHibernateTemplatehibernateTemplate;publicvoidaddTreeExt(TreeExttreeExt){this.hibernateTemplate.save(treeExt);}publicvoiddelTreeExt(inttreeExtId){this.hibernateTemplate.delete(getTreeExt(treeExtId));}publicPagergetAllTreeExt(){//TODOAuto-generatedmethodstubreturnnull;}publicTreeExtgetTreeExt(inttreeExtid){returnthis.hibernateTemplate.load(TreeExt.class,treeExtid);}publicvoidupdateTreeExt(TreeExttreeExt){this.hibernateTemplate.update(treeExt);}}通过接口来访问。

时间: 2024-09-15 03:15:48

Spring Question的相关文章

mybatis-弱弱的问一下怎么查看框架的源代码,比如Mybatis,Spring等等

问题描述 弱弱的问一下怎么查看框架的源代码,比如Mybatis,Spring等等 弱弱的问一下怎么查看框架的源代码,比如Mybatis,Spring等等,最好能够一步一 步的说明,谢谢 解决方案 http://www.zhihu.com/question/26766601 解决方案二: http://my.oschina.net/geecoodeer/blog/191815http://blog.sina.com.cn/s/blog_75ed97f401011g17.html 解决方案三: 在学

spring 注入 dao,引用的时候为null

问题描述 spring 注入 dao,引用的时候为null spring配置文件如下: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> default-autowire

2015 最简单的 Spring MVC 入门教程

2015 最简单的 Spring MVC 入门教程 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. Simplest Spring MVC Hello World Example / Tutor

Securing Spring Cloud Microservices With OAuth2

From Zero to OAuth2 in Spring cloud Today I am presenting hours of research about a (apparently) simple question: "How can I maintain security in my microservices architecture?". The task is to enable a simple but mighty possibility to secure sp

Manage Spring Boot Logs with Elasticsearch, Logstash and Kibana

下载地址:https://www.elastic.co/downloads   When time comes to deploy a new project, one often overlooked aspect is log management. ELK stack (Elasticsearch, Logstash, Kibana) is, among other things, a powerful and freely available log management solutio

Spring IoC 学习(1)

基本概念 IoC是什么? 如果这个问题要是面试的问题,那么我会这么回答. IoC(Inversion of Control 控制反转),当然它还有另一个名字,DI(Dependency Injection 依赖注入).这两个名称其实实质上指的都是同一样的东西.只不过看问题的角度是不一样的.IoC指的是,原来我们需要获得一个对象(Object)的时候,我们的第一想法就是用new.搭配下图,效果更好. 现在我们不用new了,是别人给我们的.既然是别人给的,那么,别人可以给,也可以不给.主动权这个时候

spring mvc-springmvc拦截器拦截可以处理非法字符吗?

问题描述 springmvc拦截器拦截可以处理非法字符吗? 我拦截请求,并对请求的参数做了过滤 如图: 然后到了controller里面 参数并没有改变 ,请问是我解决方法的问题吗?这种方法行的通吗?还是少了些东西?谢谢大神 解决方案 你这个拦截器有没有配置呢,调试下这个拦截器的代码有没有执行呢? 解决方案二: 你的拦截器进去了没啊?参考 http://examples.javacodegeeks.com/enterprise-java/spring/mvc/spring-mvc-handler

SI 系列入门 之 手把手构建 Maven Spring MVC 工程

SI 系列入门 之 手把手构建 Maven Spring MVC 工程 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. SI 系列入门 之 手把手构建 Spring MVC 工程 与标题仅一词之

Spring MVC 4.2.2 中最好的集成静态资源的方法

Spring MVC 4.2.2 中最好的集成静态资源的方法 太阳火神的美丽人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS.Android.Html5.Arduino.pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作. Spring MVC 4.2.2 – Best way to Add/Integra