最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用springMVC所需要的pom配置

 更新時間:2021年09月14日 16:42:42   作者:羽笑  
這篇文章主要介紹了使用springMVC所需要的pom配置,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

springMVC所需要的pom配置

配置應(yīng)用的字符編碼格式

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>

servlet api的maven依賴

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>javax.servlet-api</artifactId>
   <version>3.1.0</version>
   <scope>provided</scope>
</dependency>

javaservlet page api(jsp api)的maven依賴

<dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>javax.servlet.jsp-api</artifactId>
   <version>2.3.1</version>
   <scope>provided</scope>
</dependency>

jstl的maven依賴

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
</dependency>

spring-webmvc的maven依賴

<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <version>5.1.0.RELEASE</version>
</dependency>

commons-lang3的依賴

<dependency>
   <groupId>org.apache.commons</groupId>
   <artifactId>commons-lang3</artifactId>
   <version>3.8.1</version>
</dependency>

hibernate-validator

<dependency>
   <groupId>org.hibernate.validator</groupId>
   <artifactId>hibernate-validator</artifactId>
   <version>6.0.13.Final</version>
</dependency>

應(yīng)用版本跟jetty配置

<build>
  <plugins>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.7.v20160115</version>
    <configuration>
     <webApp>
      <contextPath>/test</contextPath>
     </webApp>
     <scanIntervalSeconds>10</scanIntervalSeconds>
    </configuration>
   </plugin>
  </plugins>
 </build>

springMVC pom依賴及配置文件

Spring MVC pom依賴

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.1.19.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.18</version>
        </dependency>
  
          <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.11.0</version>
        </dependency>
  
    </dependencies>

application.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:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context
       https://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/mvc
       https://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!-- 自動掃描指定的包,下面所有注解類交給IOC容器管理 -->
    <context:component-scan base-package="controller"/>
    <!--靜態(tài)資源過濾-->
    <mvc:default-servlet-handler />
    <!--JSON亂碼問題配置-->
    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8"/>
            </bean>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
                        <property name="failOnEmptyBeans" value="false"/>
                    </bean>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <!-- 視圖解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          id="internalResourceViewResolver">
        <!-- 前綴 -->
        <property name="prefix" value="/WEB-INF/jsp/" />
        <!-- 后綴 -->
        <property name="suffix" value=".jsp" />
    </bean>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:application.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
<!--    亂碼過濾器-->
    <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>    
</web-app>

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java編程在ICPC快速IO實現(xiàn)源碼

    Java編程在ICPC快速IO實現(xiàn)源碼

    這篇文章主要介紹了Java Fast IO in ICPC實現(xiàn)源碼,具有一定參考價值,需要的朋友可以了解下。
    2017-09-09
  • SpringBoot自定義動態(tài)數(shù)據(jù)源的流程步驟

    SpringBoot自定義動態(tài)數(shù)據(jù)源的流程步驟

    動態(tài)數(shù)據(jù)源,本質(zhì)上是把多個數(shù)據(jù)源存儲在一個?Map?中,當需要使用某一個數(shù)據(jù)源時,使用?key?獲取指定數(shù)據(jù)源進行處理,本文將給大家介紹一下SpringBoot自定義動態(tài)數(shù)據(jù)源的流程步驟,需要的朋友可以參考下
    2024-06-06
  • Socket結(jié)合線程池使用實現(xiàn)客戶端和服務(wù)端通信demo

    Socket結(jié)合線程池使用實現(xiàn)客戶端和服務(wù)端通信demo

    這篇文章主要為大家介紹了Socket結(jié)合線程池的使用來實現(xiàn)客戶端和服務(wù)端通信實戰(zhàn)demo,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步
    2022-03-03
  • springboot aop添加日志方式

    springboot aop添加日志方式

    這篇文章主要介紹了springboot aop添加日志方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • Spring?Boot?多數(shù)據(jù)源處理事務(wù)的思路詳解

    Spring?Boot?多數(shù)據(jù)源處理事務(wù)的思路詳解

    這篇文章主要介紹了Spring?Boot?多數(shù)據(jù)源如何處理事務(wù),本文單純就是技術(shù)探討,要從實際應(yīng)用中來說的話,我并不建議這樣去玩分布式事務(wù)、也不建議這樣去玩多數(shù)據(jù)源,畢竟分布式事務(wù)主要還是用在微服務(wù)場景下,對Spring?Boot?多數(shù)據(jù)源事務(wù)相關(guān)知識感興趣的朋友參考下本文
    2022-06-06
  • Java 數(shù)據(jù)庫連接(JDBC)的相關(guān)總結(jié)

    Java 數(shù)據(jù)庫連接(JDBC)的相關(guān)總結(jié)

    這篇文章主要介紹了Java 數(shù)據(jù)庫連接(JDBC)的相關(guān)總結(jié),幫助大家更好的理解和學(xué)習(xí)使用Java,感興趣的朋友可以了解下
    2021-03-03
  • Springboot集成Ehcache3實現(xiàn)本地緩存的配置方法

    Springboot集成Ehcache3實現(xiàn)本地緩存的配置方法

    EhCache是一個純Java的進程內(nèi)緩存框架,是 Hibernate 中默認的 CacheProvider,同Redis一樣,EhCache 不是純內(nèi)存緩存,它支持基于內(nèi)存和磁盤的二級緩存,本文介紹Springboot集成Ehcache3實現(xiàn)本地緩存的配置方法,感興趣的朋友一起看看吧
    2024-04-04
  • 如何實現(xiàn)nohup?java進程號一直在變方法步驟詳解

    如何實現(xiàn)nohup?java進程號一直在變方法步驟詳解

    這篇文章主要為大家介紹了如何實現(xiàn)nohup?java進程號一直在變方法步驟詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-11-11
  • java使用多線程找出最大隨機數(shù)

    java使用多線程找出最大隨機數(shù)

    這篇文章主要為大家詳細介紹了java使用多線程找出最大隨機數(shù),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • spring boot與kafka集成的簡單實例

    spring boot與kafka集成的簡單實例

    本篇文章主要介紹了spring boot與kafka集成的簡單實例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-09-09

最新評論

凌云县| 陇西县| 大城县| 黄骅市| 大石桥市| 信阳市| 彭阳县| 太谷县| 磴口县| 休宁县| 焦作市| 崇明县| 枣强县| 银川市| 满洲里市| 北票市| 察隅县| 南京市| 平罗县| 潜江市| 即墨市| 平原县| 太和县| 赤峰市| 平塘县| 永济市| 万州区| 涡阳县| 合川市| 漳平市| 盐边县| 新民市| 双牌县| 博湖县| 广汉市| 肇东市| 东乌| 宁国市| 沐川县| 吴忠市| 化德县|