java web開發中的奇葩事web.xml中context-param中的注釋


同事提交了代碼。結果除同事之外,其他人全部編譯報錯。報錯說web.xml中配置的一個bean 沒有定義。按照報錯提示,各種找,無果。

由於代碼全部都是提交到svn主干,之前也沒有做過備份,只能一步一步刪除同事提交的代碼,進行還原。

奇葩事情出現了!

 

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/context_entry.xml
classpath:/context_web.xml

<!--add by XXX-->

classpath:/GCSPcontext/context_policy_web.xml

<!--add by XXX-->

</param-value>
</context-param>

 

引入文件沒有錯誤,問題就在於這個注釋上。突然想起之前也因為在這里寫注釋,報了一個錯誤,找了很久,但是為什么把錯誤指向另一個毫不相關為的文件呢。

 

 <Could not load use
r defined filter in web.xml: org.springframework.web.filter.DelegatingFilterProx
y.
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '
shiroFilter' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
getBeanDefinition(DefaultListableBeanFactory.java:387)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMerg
edLocalBeanDefinition(AbstractBeanFactory.java:971)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:168)
Truncated. see log file for complete stacktrace

 

 

 

 

附上web.xml文件配置

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>ApplicationResources</param-value>
    </context-param>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:/context_entry.xml
            classpath:/context_web.xml

        </param-value>
    </context-param>

    
    <filter>
        <filter-name>SQLInjectFilter</filter-name>
        <filter-class>com.sinosoft.gcsp.common.util.SQLInjectFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>SQLInjectFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
  
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>GBK</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter>
        <filter-name>struts2</filter-name>
         <!-- <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> -->
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
        <init-param>
            <param-name>actionPackages</param-name>
            <param-value>com.sinosig.schedule.user.web</param-value>
        </init-param>
    </filter>
    
    <filter>
        <filter-name>shiroFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>shiroFilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

    <!--    <listener>-->
    <!--        <listener-class>-->
    <!--
        com.sinosig.framework.web.listener.FrameworkHttpSessionListener</listener-class>
    -->
    <!--    </listener>-->
    
    <error-page>
        <error-code>404</error-code>
        <location>/error404.jsp</location>
    </error-page>
    
    
    <welcome-file-list>
        <welcome-file>UIPrBefLogin.jsp</welcome-file>
    </welcome-file-list>

    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>
</web-app>

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM