ssm

作者: 殇不患_531c | 来源:发表于2020-10-14 11:53 被阅读0次
package com.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.net.URL;
\\url传值
@Controller
public class IndexController {
    @RequestMapping(value = "/test1",method = RequestMethod.GET)
    public String testController(@RequestParam int a,Model model) {
        int pa = a;
        model.addAttribute("a",pa);
        return "test1";
    }
}

//测试表单传值
    @RequestMapping(value = "/test2",method = RequestMethod.POST)
    public String test2Controller(@RequestParam String username,@RequestParam String studentnumber,Model model) {
        String name = username;
        String number = studentnumber;
        model.addAttribute("name",name);
        model.addAttribute("number",number);
        return "test1";
    }

费好大力气终于运行成功了
几个配置文件:

//jdbc.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
jdbc.username=root
jdbc.password=密码

相关文章

网友评论

      本文标题:ssm

      本文链接:https://www.haomeiwen.com/subject/vpubpktx.html