Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用@ModelAttribute注释标记方法,以便在 spring 加载具体视图之前调用此方法?
@ModelAttribute
将这样的方法添加到您的控制器:
@ModelAttribute("myString") public String getMyString() { return "my string"; }
然后可以在 JSP 中作为名为“myString”的变量访问