代码示例:
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class Test1 {
@RequestMapping("/t1/{name}")
public String test1(@PathVariable String name, Model model){
model.addAttribute("msg","name: "+name);
return "test";
}
@RequestMapping("/t2/{p1}/{p2}")
public String test2(@PathVariable int p1,@PathVariable int p2, Model model){
model.addAttribute("msg","Result: "+ (p1+p2));
return "test";
}
}
标签:web,PathVariable,springframework,风格,import,org,restful,annotation
From: https://www.cnblogs.com/maoshine/p/17649607.html