Struts2 方法动态调用,验证表签,xml配置Action
来源:互联网 发布:客户管理系统源码 编辑:程序博客网 时间:2024/06/05 20:15
Action方法的动态调用
-使用动态调用必须,在src下的struts中写入
<!-- 让struts2支持动态方法调用 附加 2.3.3 默认关闭--><constant name="struts.enable.DynamicMethodInvocation" value="true" />
动态调用的语法
- action名!方法名.action
- 案例:
- user!login.action 调用名字为user的action下面的login方法
- 通配符{*}形式的动态调用
<action name= "*User" method=”{1}” <result>{1}_success.jsp</result></action>
- 举例:
- loginUser.action 调用名字为user的action下面的login方法
验证标签
- 使用,验证标签,故此必须,现在web.xml中过滤所有的jsp
<!-- 配置Struts2 的过滤器 --> <filter> <filter-name>strut2t</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <!-- Struts2 的映射,让所有的action 都通过 struts2 的过滤器 --> <filter-mapping> <filter-name>strut2t</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <!-- 映射 所有的jsp页面 --> <filter-mapping> <filter-name>strut2t</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping>
验证标签
使用xml配置Action
- 在web.xml中配置Struts2的核心过滤器,就是上面的代码
- 建立一个类继承ActionSupport使其成为一个Action
- 在Action中,编写方法
// 如果,你不写其他方法,也可以重写,这个父接口的方法// @Override// public String execute() throws Exception {// System.out.println("zhixng");// // return Action.SUCCESS;// } //登录 public String Login()throws Exception { System.out.println("登录"+this.use.getL_name()); //代码内容 return Action.SUCCESS; //返回字符串,用来映射,调用那个结果,可以使用Struts2的常量 }
- 在src下的struts.xml内配置Action
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts> <!-- 让struts2支持动态方法调用 附加 2.3.3 默认关闭--> <constant name="struts.enable.DynamicMethodInvocation" value="true" /><!--建立packge 标签 继续继承 struts-default这个xml 指定工作区间--> <package name="sd" extends="struts-default" namespace="/"> <action name="Action名字(自定,类似javascript中id的作用)" class="这个Action的全限定名(类名加包名)" > <!-- action 执行方法 返回结果, 返回的字符串,然后匹配对应的返回结果 --> <result name="success">succeed.jsp</result> <result name="input">NewFile.jsp</result> <result name="defeated">defeated.jsp</result> </action> </package></struts>
阅读全文
0 0
- Struts2 方法动态调用,验证表签,xml配置Action
- struts2 action动态方法调用
- 框架 day27 Struts2 入门(概述,基本xml配置,动态方法调用,Action类,ServletAPI访问,结果集)
- Struts2 : Action配置 动态访问调用
- Struts2学习---基本配置,action,动态方法调用,action接收参数
- struts2动态方法调用 ActionName!methodName.action
- struts2动态方法调用 ActionName!methodName.action
- 复习Struts2之Action动态方法调用
- Struts2-02Action动态方法调用
- Struts2动态方法调用,找不到Action
- struts2 中action的动态方法调用
- struts2 动态调用action中方法
- Struts2中Action的动态调用方法
- Struts2——Action动态方法调用
- Struts2-动态调用action中的方法
- struts2 action DMI动态方法调用
- Struts2中Action的动态调用方法
- Struts2中Action的动态方法调用
- 继承、接口、final、abstrct -- JAVA 基础
- Android NDK: From Elementary to Expert Episode 23
- 记念一下
- 2017.8.17IO流 的案列
- 【后台】菜单管理界面菜单项增加自定义字段
- Struts2 方法动态调用,验证表签,xml配置Action
- hdu 6140
- 51 nod 1435 位数阶乘
- 剑指Offer_面试题33_把数组排成最小的数
- Android Binder机制浅析(一)
- 8.17--练习赛B题--River Hopscotch(二分)
- ARM学习笔记三
- IO流
- Python3爬虫代理服务器与cookie的使用