您的位置:首页 > 编程语言 > Java开发

MESSL(maven + extjs + spring portlet mvc + spring web flow + liferay )整合架构 2

2013-02-23 14:56 621 查看
因为这是个基于spring的web应用,所以当然我们从web.xml看起:
<?xml version="1.0" encoding="ISO-8859-1"?> <web-app 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"     version="2.4">      <!--       - Location of the XML file that defines the root application context       - Applied by ContextLoaderListener.       -->     <context-param>         <param-name>contextConfigLocation</param-name>         <param-value>             /WEB-INF/config/application-config.xml         </param-value>     </context-param>      <!--       - Loads the root application context of this web app at startup.       - The application context is then available via       - WebApplicationContextUtils.getWebApplicationContext(servletContext).     -->     <listener>         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>     </listener>          <servlet>         <servlet-name>ViewRendererServlet</servlet-name>         <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class>     </servlet>          <servlet-mapping>         <servlet-name>ViewRendererServlet</servlet-name>         <url-pattern>/WEB-INF/servlet/view</url-pattern>     </servlet-mapping>        </web-app>
在第23-25行表示了我们进入spring框架,这个大家都知道。

在第11-16行,定义了Spring的配置文件,我当时设计时候,还是采用了多配置文件结构,所以在应用层,我只指定了这1个配置文件,这个配置文件定义了Spring应用的一些宏观的内容:
这个文件在/WEB-INF/config/applicatino-config.xml中:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xmlns:context="http://www.springframework.org/schema/context"           xmlns:tx="http://www.springframework.org/schema/tx"        xsi:schemaLocation="http://www.springframework.org/schema/beans            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd            http://www.springframework.org/schema/context            http://www.springframework.org/schema/context/spring-context-3.0.xsd" >                 <!-- Activates annotation-based bean configuration -->     <context:annotation-config />          <!-- Scans for application @Components to deploy to spring container -->     <context:component-scan base-package="xx.xx.xx.handlers" />     <context:component-scan base-package="xx.xx.xx.service.impl" />     <context:component-scan base-package="xx.xx.xx.portlet" />      </beans>
我这里只开启了注解配置,并且启用了java包扫描,所以被我罗列的包中的所有Spring注解都会被扫描到,并且在Spring Application Context加载时自动实例化对应的被标注的 bean.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐