我能用Spring MVC做类似这样的事吗?
@RequestMapping(value = "/{root}")
public abstract class MyBaseController {
@PathVariable(value = "root")
protected ThreadLocal<String> root;
}
@Controller
public class MyController extends MyBaseController {
@RequestMapping(value = "/sayHello")
@ResponseBody
public String hello() {
return "Hello to " + this.root.get();
}
}
当我请求http://..../roberto/sayHello
时,我会得到以下响应:
Hello to roberto