关于springmvc的web.xml pom.xml springmvc.xml可以点左边的springmvc全部配置文件获得
package org.example.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class RestfulDemoController {
// 传统的get方式 http://localhost/addRestful?a=100&b=200
@RequestMapping("/addRestful")
public String Test1(int a, int b, Model model) {
int res = a + b;
model.addAttribute("msg", "结果是:" + res);
return "test.jsp";
}
// restfulm风格 http://locahost/addRestul2/100/200
@RequestMapping("/addRestful2/{a}/{b}")
public String Test2(@PathVariable int a, @PathVariable int b, Model model) {
int res = a + b;
model.addAttribute("msg", "结果是:" + res);
return "test.jsp";
}
}
作者:admin 创建时间:2022-12-19 20:48
最后编辑:admin 更新时间:2022-12-19 20:55
最后编辑:admin 更新时间:2022-12-19 20:55