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=密码