bootscrap+angular+ssm整合(上)

實體類

引入插件

配置文件如下:


springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:tx="http://www.springframework.org/schema/tx" 
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
                           http://www.springframework.org/schema/tx 
                           http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context-3.2.xsd
                           http://www.springframework.org/schema/aop
                           http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
                           http://www.springframework.org/schema/mvc 
                           http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
                           
     <!-- 包掃描 -->
     <context:component-scan base-package="com.frank.controller"></context:component-scan>
     
     <!-- 視圖解析器 -->
     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/"></property>
      <property name="suffix" value=".jsp"></property>
     </bean>
     
     <!-- 將springMvc不能處理的請求交給tomcat -->
     <mvc:default-servlet-handler/>
     
      <!--啓用註釋-->
     <mvc:annotation-driven/>
</beans>

mybatis-config.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<plugins>
   <!-- com.github.pagehelper爲PageHelper類所在包名 -->
   <plugin interceptor="com.github.pagehelper.PageInterceptor">
       <!-- 使用下面的方式配置參數,後面會有所有的參數介紹 ,分頁合理化參數-->
       <property name="reasonable" value="true"/>
</plugin>
</plugins>
</configuration>


Springmvc.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:tx="http://www.springframework.org/schema/tx" 
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
                           http://www.springframework.org/schema/tx 
                           http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context-3.2.xsd
                           http://www.springframework.org/schema/aop
                           http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
                           http://www.springframework.org/schema/mvc 
                           http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
                           
     <!-- 包掃描 -->
     <context:component-scan base-package="com.bw.controller"></context:component-scan>
     
     <!-- 視圖解析器 -->
     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/"></property>
      <property name="suffix" value=".jsp"></property>
     </bean>
     
     <!-- 將springMvc不能處理的請求交給tomcat -->
     <mvc:default-servlet-handler/>
     
      <!--啓用註釋-->
     <mvc:annotation-driven/>
</beans>

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                 xmlns="http://java.sun.com/xml/ns/javaee"   
                 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                                                   http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
                                                   id="WebApp_ID" version="3.0">
  <!-- 配置Spring的字符集過濾器 -->
  <filter>
  <filter-name>encoding</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>
  </filter>
  <filter-mapping>
  <filter-name>encoding</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <!-- 配置SpringMvc的前端控制器 -->
  <servlet>
  <servlet-name>mvc</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:springmvc.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
  <servlet-name>mvc</servlet-name>
  <url-pattern>/</url-pattern>
  </servlet-mapping>
  
  
  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <!-- Spring的監聽器,用於監聽web應用啓動事件,以便在web應用啓用時,將
  Spring的IOC容器進行實例化,並存放在application作用域中 -->
  <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>


  
</web-app>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章