请求参数绑定集合类型
生活随笔
收集整理的這篇文章主要介紹了
请求参数绑定集合类型
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Title</title>
</head>
<body><%--把數(shù)據(jù)封裝Account類中,類中存在list和map的集合--%><form action="param/saveAccount" method="post">姓名:<input type="text" name="username" /><br/>密碼:<input type="text" name="password" /><br/>金額:<input type="text" name="money" /><br/>用戶姓名:<input type="text" name="list[0].uname" /><br/>用戶年齡:<input type="text" name="list[0].age" /><br/>用戶姓名:<input type="text" name="map['one'].uname" /><br/>用戶年齡:<input type="text" name="map['one'].age" /><br/><input type="submit" value="提交" /></form></body>
</html>
package com.learn.controller;import com.learn.domain.Account;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;/*** 請求參數(shù)綁定*/
@Controller
@RequestMapping("/param")
public class ParamController {/*** 請求參數(shù)綁定把數(shù)據(jù)封裝到JavaBean的類中* @return*/@RequestMapping("/saveAccount")public String saveAccount(Account account){System.out.println("執(zhí)行了...");System.out.println(account);return "success";}}
?
總結(jié)
以上是生活随笔為你收集整理的请求参数绑定集合类型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 配置解决中文乱码的过滤器
- 下一篇: 自定义类型转换器代码编写