Disclaimer: This article is not a problem. It is just a small Vulnerability I found when running the "my Think Tank" project. I would like to share it with mldn and hope you will discuss it actively. The following problems often occur when running this project: ForgotToCallClose ()OnYourSession? In severe cases, the following exception occurs: Org. hibernate. Exception. genericjdbcexception:CocouldNotExecuteQuery The reason is that spring initializes twice: The first is in Web. xml. <Context-param> <Param-Name> contextconfiglocation </param-Name> <Param-value> /WEB-INF/classes/applicationcontext. xml </Param-value> </Context-param> Second in struts-config.xml <Plug-in Classname = "org. springframework. Web. Struts. contextloaderplugin"> <Set-PropertyProperty = "contextconfiglocation" Value = "/WEB-INF/classes/applicationcontext. xml"/> </Plug-in> So how can we initialize it only once? You cannot delete one entry. An exception occurs when you delete the entry: Org. springframework. Beans. Factory. beandefinitionstoreexception: IoexceptionParsingXMLDocumentFromServletcontextResource[/WEB-INF/applicationcontext. xml]; NestedExceptionIsJava. Io. filenotfoundexception:CocouldNotOpenServletcontextResource[/WEB-INF/applicationcontext. xml] Java. Io. filenotfoundexception:CocouldNotOpenServletcontextResource[/WEB-INF/applicationcontext. xml] From this information we can see that Tomcat boot will load once, and the default directory is under/WEB-INF. Spring will be initialized once even if you delete it. You can only delete 2nd entries. Indeed, after deletion, the exception will not appear. Ensure that spring is only initialized once★★★Question supplement★★★(20:17:11) There is a solution if you add this file action-servlet.xml! 1. Put applicationcontext. XML in/WEB-INF. 2. Add only action-servlet.xml to the plug-in at the second place, the Code is as follows: <Plug-in Classname = "org. springframework. Web. Struts. contextloaderplugin"> <Set-PropertyProperty = "contextconfiglocation" Value = "/WEB-INF/action-servlet.xml"/> In addition, put applicationcontext. xml also put/WEB-INF/, in the web. xml file can also write like this: Org. springframework. Web. Context. contextloaderlistener ★★★Question supplement★★★(20:19:11) Filtered and sent again! [Listener] [Listener-class] Org. springframework. Web. Context. contextloaderlistener [/Listener-class] [/Listener] ★★★Question supplement★★★(20:22:26) HoweverListenerI guess Tomcat cannot be used. ★★★Question supplement★★★(17:12:09) I have read the above supplements and have any questions. Please try the following methods: Directory structure. See the following figure. Http://hi.baidu.com/java%5Forg/album/item/c06680faef9573d0b58f3127.html Download the configuration file: Http://pickup.mofile.com/5707700987067459 ★★★Question supplement★★★(11:46:12) The new configuration file: Http://pickup.mofile.com/7718233563555967 If you cannot download it, I cannot download it! Please do not use the previous ★★★Question supplement★★★(11:50:55) Thank you for your participation! Download it! |