3.2 Action
在Controller之中定义的public方法称为Action。Action是请求的最小单位。Action方法必须在Controller中定义,且必须是public可见性。
- public class HelloController extends Controller {
- public void index() {
- renderText("此方法是一个action");
- }
- public String test() {
- return "index.html";
- }
- }
以上代码中定义了两个Action:HelloController.index()、HelloController.test()。
Action可以有返回值,返回值可在拦截器中通过invocation.getReturnValue() 获取到,以便进行render控制。