第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

pringMVC-批量注冊(cè)員工 學(xué)習(xí)筆記

標(biāo)簽:
Java

jsp

<%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <body>     <form action="${pageContext.request.contextPath}/emp/addAll.action" method="POST">        <table border="2" align="center">            <caption><h2>批量注册员工</h2></caption>            <tr>                <td><input type="text" name="empList[0].username" value="哈哈"/></td>                <td><input type="text" name="empList[0].salary" value="7000"/></td>            </tr>            <tr>                <td><input type="text" name="empList[1].username" value="呵呵"/></td>                <td><input type="text" name="empList[1].salary" value="7500"/></td>            </tr>            <tr>                <td><input type="text" name="empList[2].username" value="班长"/></td>                <td><input type="text" name="empList[2].salary" value="8000"/></td>            </tr>            <tr>                <td><input type="text" name="empList[3].username" value="键状哥"/></td>                <td><input type="text" name="empList[3].salary" value="8000"/></td>            </tr>            <tr>                <td><input type="text" name="empList[4].username" value="绿同学"/></td>                <td><input type="text" name="empList[4].salary" value="9000"/></td>            </tr>            <tr>                <td colspan="2" align="center">                    <input type="submit" value="批量注册"/>                </td>            </tr>        </table>    </form>  </body></html>

java

import java.util.ArrayList;import java.util.List;/** * 封装多个Emp的对象  * @author AdminTC */public class Bean {    private List<Emp> empList = new ArrayList<Emp>();    public Bean(){}    public List<Emp> getEmpList() {        return empList;    }    public void setEmpList(List<Emp> empList) {        this.empList = empList;    }}-----///** * 员工 * @author AdminTC */public class Emp {    private String username;//姓名    private Double salary;//薪水    public Emp(){}    public String getUsername() {        return username;    }    public void setUsername(String username) {        this.username = username;    }    public Double getSalary() {        return salary;    }    public void setSalary(Double salary) {        this.salary = salary;    }}//-----import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;/** * 员工模块 * @author AdminTC */@Controller@RequestMapping(value="/emp")public class EmpAction {    /**     * 批量添加员工     */    @RequestMapping(value="/addAll",method=RequestMethod.POST)    public String addAll(Model model,Bean bean) throws Exception{        for(Emp emp:bean.getEmpList()){            System.out.println(emp.getUsername()+":"+emp.getSalary());        }        model.addAttribute("message","批量增加员工成功");        return "/jsp/ok.jsp";    }}

spring.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:mvc="http://www.springframework.org/schema/mvc"      xmlns:context="http://www.springframework.org/schema/context"      xsi:schemaLocation="      http://www.springframework.org/schema/beans       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd      http://www.springframework.org/schema/mvc      http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd      http://www.springframework.org/schema/context      http://www.springframework.org/schema/context/spring-context-3.0.xsd      ">    <!-- Action,让springioc容器去扫描带@Controller的类 -->    <context:component-scan base-package="cn.itcast.javaee.springmvc.app22"/></beans>

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消