zoukankan      html  css  js  c++  java
  • springMVC---级联属性

    承接一二章

    结构

    index.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Hello World</title>
    
        <br> <br>
      <form action="springMVC/testPojo" method="get">
     <input type="text" name="username"/>
     <input type="text" name="password"/>
     <input type="text" name="adress.province"/>
      <input type="text" name="adress.city"/>
     <input type="submit" value="submit"/>
     </form>
      </body>
    </html>
    

     Adress.java

    package com.hdxy.pojo;
    
    public class Adress {
        private String province;
        private String city;
    
        @Override
        public String toString() {
            return "Adress [province=" + province + ", city=" + city + "]";
        }
    
        public String getProvince() {
            return province;
        }
    
        public void setProvince(String province) {
            this.province = province;
        }
    
        public String getCity() {
            return city;
        }
    
        public void setCity(String city) {
            this.city = city;
        }
    }

    User.java

    package com.hdxy.pojo;
    
    public class User {
      private String username;
      private String password;
        private Adress adress;
    
        @Override
        public String toString() {
            return "User [username=" + username + ", password=" + password + ", adress=" + adress + "]";
        }
    
        public String getUsername() {
            return username;
        }
    
        public void setUsername(String username) {
            this.username = username;
        }
    
        public String getPassword() {
            return password;
        }
    
        public void setPassword(String password) {
            this.password = password;
        }
    
        public Adress getAdress() {
            return adress;
        }
    
        public void setAdress(Adress adress) {
            this.adress = adress;
        }
    }

    test.java

    package com.hdxy.domian;
    
    import java.lang.reflect.Method;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.CookieValue;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    
    import com.hdxy.pojo.User;
    
    @RequestMapping("springMVC")
    @Controller
    public class Test {
        
       final public String SUCCESS="loginSuccess";
      
     
       @RequestMapping(value="/testPojo")
       public String test(User user){
           System.out.println("testRequestParam:"+user);
           return SUCCESS;
       }
    }
  • 相关阅读:
    Robot Framework自动化测试 ---视频与教程免费分享
    我读《2017软件测试行业调查报告》
    『性能测试』文章大汇总
    作为一个测试,应该怎样分工呢?
    软件测试流程进阶----软件测试总结心得
    JMeter 聚合报告之 90% Line 参数说明
    JMeter使用技巧
    自动化基础普及之selenium的解释
    Robot Framework自动化测试(四)--- 分层思想
    mysql的几种join 及 full join 问题
  • 原文地址:https://www.cnblogs.com/lnthz/p/8167400.html
Copyright © 2011-2022 走看看