2. integrate Spring
A) web. xml file configuration
<Context-param> <param-Name> webapprootkey </param-Name> <param-value> webapp. root </param-value> </context-param> <param-Name> contextconfiglocation </param-Name> <param-value>/WEB-INF/applicationcontext *. XML, classpath *: applicationcontext *. XML, classpath *: prediction_config.xml </param-value> </context-param> <! -- Log4j config ------- the webapp must be defined before spring context listener or above. root environment variables cannot be used in the log4j configuration file --> <listener-class> Org. springframework. web. util. log4jconfiglistener </listener-class> </listener> <! -- Spring applicationcontext loading --> <listener-class> org. springframework. Web. Context. contextloaderlistener </listener-class> </listener> <! -- Character encoding 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> <init-param> <param-Name> forceencoding </param-Name> <param-value> true </param-value> </init-param> </Filter> <filter-mapping> <filter-Name> Encodingfilter </filter-Name> <URL-pattern>/* </url-pattern> </filter-mapping> <! -- Spring refresh introspector to prevent memory leakage --> <listener-class> org. springframework. Web. util. introspectorcleanuplistener </listener-class> </listener>