jfinal框架基础

jfinal 约定优于配置

配置是第一层,约定就是第二层(简单理解)

http://localhost/hello/methodName 将访问到 HelloController.methodName() 方法。

public void configRoute (Routes me){
me .add ("/hello",HelloController.class);
}

 

注解

假定UserController 的 controllerKey值为“/user",在使用了@ActionKey(“/login")注解以后,actionKey由原来的"“/user/login”变为了“login”。该注解还可以让 actionKey中使用减号或数字等字符,如"/user/123-456”。

 

action

Action Controller 以及在其中定义的 public 无参方法称为一个Action。

Action是请求的最小单位。

Action方法必须在Controller中声明,该方法必须是public可见性且没有形参。

 

getPara 方法

getPara系列方法 Controller提供了getPara系列方法用来从请求中获取参数。

getPara系列方法分为两种类型。

第一种类型为第一个形参为String的getPara系列方法。该系列方法是对 HttpServletRequest.getParameter(String name)的封装﹐这类方法都是转调了HttpServletRequest.getParameter(String name)。

第二种类型为第一个形参为int或无形参的getPara系列方法。该系列方法是去获取urlPara中所带的参数值。getParaMap 与getParaNames分别对应HttpServletRequest的getParameterMap 与getParameterNames。

记忆技巧:第一个参数为String类型的将获取表单或者url中问号挂参的域值。第一个参数为int或无参数的将获取urlPara中的参数值。

 

getModel 方法

getModel系列方法 getModel用来接收页面表单域传递过来的model对象,表单域名称以"mod&lName.attrName"方式命名,除了支持JFinal的 Model对象以外,getModel同时也支持传统的Java Bean。

posted @ 2022-07-29 14:54  kuaiquxie  阅读(55)  评论(0)    收藏  举报