javaweb第三次作业

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>product</title>
</head>
<body style="font-size: 30px">
    <form action="addProduct" >
      产品名称:<input type="text" name="name" value="" ><br>
      产品价格:<input type="text" name="price" value=""><br>
      <input type="submit" value="增加商品">
    </form>
</body>
</html>

package com.example.demo.work1;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Product2 {
    private String name;
    private Float price;

    public String getName(){
        return name;
    }

    public Float getPrice() {
        return price;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    @RequestMapping("/addProduct")
    public String Product(String name,Float price){
        System.out.println("您输入的信息是:"+name+":"+price);
        return "OK";
    }
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form action="information">
      请输入用户姓名:<input type="text" name="name" value=""><br>
      选择性别:
      <input type="radio" name="sex" value="男">男
      <input type="radio" name="sex" value="女">女<br>
      选择密码提示问题:<select name="question">
      <option value="母亲生日">母亲生日</option>
      <option value="宠物名称">宠物名称</option>
      <option value="电脑配置">电脑配置</option>
    </select><br>
      请输入问题答案:<input type="text" name="answer" value=""><br>
      请选择个人爱好:<br>
      <input type="checkbox" name="like" value="dance">唱歌跳舞
      <input type="checkbox" name="like" value="dance">上网冲浪
      <input type="checkbox" name="like" value="dance">户外登山<br>
      <input type="checkbox" name="like" value="dance">体育运动
      <input type="checkbox" name="like" value="dance">读书看报
      <input type="checkbox" name="like" value="dance">欣赏电影<br>

      <input type="submit" value="提交">
    </form>
</body>
</html>

package com.example.demo.work1;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Information {
    private String name;
    private String sex;
    private String question;
    private String answer;
    private String like[];

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public String[] getLike() {
        return like;
    }

    public void setLike(String[] like) {
        this.like = like;
    }

 @Override
    public String toString() {
        return "Information{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", question='" + question + '\'' +
                ", answer='" + answer + '\'' +
                ", like=" + Arrays.toString(like) +
                '}';
    }

    @RequestMapping("/information")
    public String getInformatuon(Information information){
        System.out.println(information);
        return "OK";
    }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值