tomcat服务器启动,Filter 的构造函数被调用了两次,doFilter函数调用了一次,
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tomcat服务器启动,Filter 的构造函数被调用了两次,doFilter函数调用了一次,相关的知识,希望对你有一定的参考价值。
tomcat服务器启动,Filter 的构造函数被调用了两次,doFilter函数调用了一次,构造函数被调用两次怎么解决
参考技术A No matching bean of type [com.hundsun.maw.manage.log.getlog.TestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)Could not autowire field: private com.hundsun.maw.manage.log.getlog.TestService com.hundsun.maw.manage.usergeneral.action.UserGeneralAction.testservice; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.hundsun.maw.manage.log.getlog.TestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)
Error creating bean with name 'userGeneralAction': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.hundsun.maw.manage.log.getlog.TestService com.hundsun.maw.manage.usergeneral.action.UserGeneralAction.testservice; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.hundsun.maw.manage.log.getlog.TestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)
Unable to instantiate Action, userGeneralAction, defined for 'searchUserGeneral' in namespace '/userGeneralSearch'Error creating bean with name 'userGeneralAction': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.hundsun.maw.manage.log.getlog.TestService com.hundsun.maw.manage.usergeneral.action.UserGeneralAction.testservice; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.hundsun.maw.manage.log.getlog.TestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)追问
???
Filter的声明周期
1.首先是在服务器在启动的时候,执行Filter的构造函数,然后是init方法。
2.在请求到达的时候调用doFilter方法里的语句。
3.执行chain.doFilter函数:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("执行了doFilter"); chain.doFilter(request, response); System.out.println("返回了doFilter"); }
每一次拦截请求时都会调用。
参数:
ServletRequest request
> 请求报文
ServletResponse response
> 响应报文
FilterChain chain
> 该对象的作用就是放行请求:
可以通过 chain.doFilter(request,response) 放行请求。
当调用chain.doFilter()就相当于调用目标资源的service()方法。
4.服务器运行请求的web资源。
4.再之后是doFilter的剩下的语句。
5.最后是destroy方法
以上是关于tomcat服务器启动,Filter 的构造函数被调用了两次,doFilter函数调用了一次,的主要内容,如果未能解决你的问题,请参考以下文章
启动tomcat后struts框架报异常严重: Exception starting filter struts2 Unable to load configuration.
Java安全之基于Tomcat的Servlet&Listener内存马