大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

專注Java教育14年 全國咨詢/投訴熱線:400-8080-105
動力節點LOGO圖
始于2009,口口相傳的Java黃埔軍校
首頁 hot資訊 SpringMVC的form表單處理

SpringMVC的form表單處理

更新時間:2021-09-10 09:59:56 來源:動力節點 瀏覽1186次

針對前端傳送過來的一個表單中的數據如果后臺對應的action方法中沒有跟form表單組成的實體相同名稱的入參;那么就會報出異常:

先上一段前端form表單對應的一個action方法,注意其中沒有任何的入參;

@RequestMapping("/profile")
public String displayProfile() {
  return "profile/profilePage";
}

前端代碼如下:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="layout/default">
<head lang="en">
    <title>Your profile</title>
</head>
<body>
<div class="row" layout:fragment="content">
    <h2 class="indigo-text center">Personal info</h2>
    <form th:action="@{/profile}" method="post" th:object="${profileForm}" class="col m8 s12 offset-m2">
        <div class="row">
            <div class="input-field col s6">
                <input  th:filed="${profileForm.twitterHandle}" id="twitterHandle" type="text"/>
                <label for="twitterHandle">Twitter handle</label>
            </div>
            <div class="input-field col s6">
                <input  th:field="${profileForm.email}" id="email" type="email"/>
                <label for="email">Email</label>
            </div>
        </div>
        <div class="row">
            <div class="input-field col s6">
                <input th:field="${profileForm.birthDate}" id="birthDate" type="text"/>
                <label for="birthDate">Birth Date</label>
            </div>
        </div>
        <div class="row s12">
            <button class="btn waves-effect waves-light" type="submit" name="save">Submit
                <i class="mdi-content-send right"></i>
            </button>
        </div>
    </form>
</div>
</body>
</html>

運行并訪問應用回展示如下的前端錯誤。

后端會報:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "profile", template might not exist or might not be accessible by any of the configured Template Resolvers

仔細查看了一下是由于自己沒有在controler方法中加入請求參數,將action方法變為如下即可通過

@RequestMapping("/profile")
    public String displayProfile(ProfileForm profileForm) {        
        return "profile/profilePage";
    }

以上就是動力節點小編介紹的"SpringMVC的form表單處理",希望對大家有幫助,想了解更多可查看SpringMVC教程。動力節點在線學習教程,針對沒有任何Java基礎的讀者學習,讓你從入門到精通,主要介紹了一些Java基礎的核心知識,讓同學們更好更方便的學習和了解Java編程,感興趣的同學可以關注一下。

提交申請后,顧問老師會電話與您溝通安排學習

免費課程推薦 >>
技術文檔推薦 >>
主站蜘蛛池模板: 成人网在线视频 | 亚洲天堂不卡 | 天天做天天做天天综合网 | 国产福利在线小视频 | 日本欧美一区二区三区 | 福利观看 | 亚洲欧美在线免费 | 精品动漫一区二区三区 | 亚洲精品一区二区在线观看 | 99久久精品国产免看国产一区 | 国产香港特级一级毛片 | 亚洲国产成+人+综合 | 欧美三级做爰视频 | 91私拍 | 免费看欧美日韩一区二区三区 | 亚洲免费播放 | 在线免费观看亚洲 | 狠狠色噜噜狠狠狠狠97不卡 | 狠狠干天天 | 看真人视频一一级毛片 | 国产成人高清亚洲一区91 | 一区二区三区在线观看视频 | 久久免费高清视频 | 久久青草18免费观看网站 | 色偷偷亚洲精品一区 | 四虎影视永久地址www成人 | 久久久久久久久久久9精品视频 | 无夜精品久久久久久 | 欧美欧美aaaaa一级毛片 | 国产精品人成在线播放新网站 | 久久精品动漫 | 亚洲天堂h | 国产亚洲欧美一区 | 久久精品国产99久久72 | 国产情侣久久精品 | 亚洲另类中文字幕 | 久久久青青久久国产精品 | 亚洲va国产va欧美va综合 | 老头与老头同性tube可播放 | 884hutv四虎永久7777 | 美女福利视频一区二区 |