Struts 之 Action
一、Action的作用 属于Controller
-和Servlet来比较使用
-处理用户请求
处理具体业务逻辑的小控制器
-调用后台逻辑
业务逻辑
数据逻辑
-页面跳转
返回ActionForward
被配置中struts-config.xml文件中
Action的配置和使用
-Action的定义
定义一个类继承Action
覆盖Action的execute方法
例如:
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
return super.execute(mapping, form, request, response);
}
-Action的声明
配置在struts-config.xml配置文件中,例如:
<action path="/login" type="com.zhaofei.action.LoginAction" name="loginForm"></action>
-Action的调用
表单调用
URL调用
超链接调用
JavaScript调用
JavaScript脚本使用
使用Struts的流程
-定义Action
-定义Formbean
-配置Action、formbean
Action
formBean
-配置映射结果
<forward name="welcome" path="/pages/Welcome.jsp"></forward>
<forward name="failure" path="/pages/Failures.jsp"></forward>
-调用
action="<%=path%>/login.amaker"
学习_Java_Base_Struts_Action
最新推荐文章于 2021-02-16 21:23:43 发布