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

SpringMVC?RESTFul實戰(zhàn)案例訪問首頁

 更新時間:2022年05月28日 15:28:44   作者:把蘋果咬哭的測試筆記  
這篇文章主要為大家介紹了SpringMVC?RESTFul實戰(zhàn)案例訪問首頁,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

SpringMVC RESTFul訪問首頁實現(xiàn)

一、新建 index.html

在 webapp\WEB-INF\templates 下新建首頁 index.html。

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8" >
    <title>Title</title>
</head>
<body>
<h1>首頁</h1>
<a th:href="@{/employee}" rel="external nofollow" >查看員工信息</a>
</body>
</html>

二、配置視圖控制器

在 springMVC.xml 配置文件里,配置首頁的 view-controller。另外還要開啟注解驅(qū)動。

<?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 http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
    <!-- 自動掃描包 -->
    <context:component-scan base-package="com.pingguo.rest"></context:component-scan>
    <!-- 配置Thymeleaf視圖解析器 -->
    <bean id="viewResolver" class="org.thymeleaf.spring5.view.ThymeleafViewResolver">
        <property name="order" value="1"/>
        <property name="characterEncoding" value="UTF-8"/>
        <property name="templateEngine">
            <bean class="org.thymeleaf.spring5.SpringTemplateEngine">
                <property name="templateResolver">
                    <bean class="org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver">
                        <!-- 視圖前綴 -->
                        <property name="prefix" value="/WEB-INF/templates/"/>
                        <!-- 視圖后綴 -->
                        <property name="suffix" value=".html"/>
                        <property name="templateMode" value="HTML5"/>
                        <property name="characterEncoding" value="UTF-8" />
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
    <!--
        path:設(shè)置處理的請求地址
        view-name:設(shè)置請求地址所對應(yīng)的視圖名稱
    -->
    <mvc:view-controller path="/" view-name="index"></mvc:view-controller>
    <!--開啟 mvc 的注解驅(qū)動-->
    <mvc:annotation-driven />
</beans>

三、Idea 部署配置

點擊 配置。

繼續(xù)按照順序點擊配置。

選擇要部署的 war 包,點擊確定。

最后為了方便訪問,修改下上下文(不改也可以)。

點擊部署,成功后自動打開首頁。

感謝《尚硅谷》的學(xué)習(xí)資源。

以上就是SpringMVC RESTFul實戰(zhàn)案例訪問首頁的詳細內(nèi)容,更多關(guān)于SpringMVC RESTFul訪問首頁的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評論

新龙县| 麟游县| 铁岭县| 闽清县| 元谋县| 英德市| 盐山县| 吉林省| 嘉禾县| 墨江| 孟津县| 马龙县| 宁夏| 紫阳县| 阿拉善左旗| 邢台县| 德兴市| 虎林市| 安义县| 抚顺市| 郓城县| 木兰县| 林西县| 平谷区| 宁南县| 德清县| 万山特区| 武鸣县| 怀远县| 临海市| 岳普湖县| 饶阳县| 睢宁县| 红河县| 德昌县| 辽阳县| 新田县| 石嘴山市| 华容县| 太仓市| 宁津县|