@Action和@Actions注解详解
package org.rabbitx.web.struts2.annotation; import org.apache.log4j.Logger; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.Actions; import com.opensymphony.xwork2.ActionSupport; public class ActionAnnotationAction extends ActionSupport{ private static final long serialVersionUID = -875096768864638232L; private Logger logger = Logger.getLogger(ActionAnnotationAction.class); /** * * 1. 使用@Action注解改变Convention plug约定的action与url之间的映射关系,,原来的约定被覆盖并不再起作用。 * 原来约定地址:http://localhost:8080/org.rabbitx.web.struts2.convention/annotation/action-annotation * 重写后的地址:http://localhost:8080/org.rabbitx.web.struts2.convention/execute */ @Override @Action("/execute") public String execute() throws Exception { logger.info("------ConventionAnnotationAction-----execute-------"); return SUCCESS; } /** * 2. 使用@Actions注解解决一个ACTION中的一个方法,响应多个不同的URL。 * 实际项目开发过程中有很大的几率碰到Action的处理相同,但是最终跳转的页面不同的情况。将@Actions和@Action组合起来用即可解决这样的需求。 * 访问地址:http://localhost:8080/org.rabbitx.web.struts2.convention/multi-url-a * http://localhost:8080/org.rabbitx.web.struts2.convention/multi-url-b * http://localhost:8080/org.rabbitx.web.struts2.convention/multi-url-c */ @Actions({ @Action("/multi-url-a"), @Action("/multi-url-b"), @Action("/multi-url-c") }) public String multiUrl2SingleAction() { logger.info("------ConventionAnnotationAction-----multiUrl2SingleAction-------"); return SUCCESS; } /** * 3. 使用@Action注解解决一个ACTION中的多个方法,其中每个方法响应不同的URL. * 4. 注解@Action的value值使用相对路径. * "relative-action-url"没有以"/"开头,表示使用了相对路径。 * 使用相对路径后,访问此方法需要使用 namespace + url 的方式,即/annotation/relative-action-url。 * 使用相对路径后,响应的页面资源默认放在对应的命名空间目录下,即/content/annotation/relative-action-url.jsp。 * 访问地址:http://localhost:8080/org.rabbitx.web.struts2.convention/annotation/relative-action-url */ @Action("relative-action-url") public String relativeActionUrl() { logger.info("------ConventionAnnotationAction-----relativeActionUrl-------"); return SUCCESS; } /** * 5. 注解@Action的value值使用绝对路径. * "/absolute-action-url"以"/"开头,表示使用了绝对路径。 * 使用绝对路径后,访问此方法可以直接使用地址,即/absolute-action-url。 * 使用绝对路径后,响应的页面资源默认放在跟目录对应目录下,即/content/absolute-action-url.jsp。 * 访问地址:http://localhost:8080/org.rabbitx.web.struts2.convention/absolute-action-url */ @Action("/absolute-action-url") public String absoluteActionUrl() { logger.info("------ConventionAnnotationAction-----absoluteActionUrl-------"); return SUCCESS; } }
相关推荐
默认包路径包含action,actions,struts,struts2的所有包都会被struts作为含有Action类的路径来搜索。你可以通过设置struts.convention.package.locators属性来修改这个配置。如: <constant name="struts.convention....
从struts2.1版本开始,Convention Plugin作为替换替换Codebehind Plugin来实现Struts2的零配置。• 包命名习惯来指定Action位置• 命名习惯制定结果(支持JSP,FreeMarker等)路径• 类名到URL的约定转换• 包名...
struts2 注解与Action相关的两个Annotation是@Action 和@Actions2)@Action中可指定一个value属性。类似于指定<action name=””/>属性值
从struts2.1版本开始,Convention Plugin作为替换替换Codebehind Plugin来实现Struts2的零配置。 • 包命名习惯来指定Action位置 • 命名习惯制定结果(支持JSP,FreeMarker等)路径 • 类名到URL的约定转换 • 包名...
struts.action.extension The URL extension to use to determine if the request is meant for a Struts action 用URL扩展名来确定是否这个请求是被用作Struts action,其实也就是设置 action的后缀,例如login....
struts2 chm 程序包 org.apache.struts2 接口概要 接口 说明 StrutsStatics Constants used by Struts. 类概要 类 说明 RequestUtils Request handling utility class. ServletActionContext Web-specific ...
│深入浅出STRUTS 2 Struts Ti却发现了二者在技术与开发人员这两个层面上的共同之处,不久之后,两个项目就在WebWork的技术基础上进行了合并2。 当我们说起WebWork的时候,我们实际上说的是两个项目——XWork和...
strutsActions 测试用例 strutsActions 测试用例
import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import org.apache.struts.actions.DispatchAction等缺少
@Action 配置访问路径,和方法绑定 @Result 结果集配置 struts2 和 spring 整合 struts2 的 Action 使用 spring 注解,被 spring 管理 @Controller spring 表现层 bean @Scope 配置 Action 为多例 Spring Data...
ROS2官网教程学习笔记理解ROS2 actions动作背景准备条件学习内容1. 启动节点2. 使用 actions动作3. ros2 node info4. ros2 action list4.1 ros2 action list -t5. ros2 action info6. ros2 interface show7. ros2 ...
· 使用注释: 使用Struts 2开发的应用可以使用Java 5注释,作为XML和Java属性配置之外的一个替代办法。注释尽量减少了对XML的需要。Action、拦截器、验证及类型转换方面都有注释。 插入: 只要把插件JAR文件放到\WEB-...
这本书将带你一起探讨Struts 2应用的方方面面,如架构、配置、实现Actions和对验证与国际化的支持等。除了这些,本书还专注于实践,用大量的代码和技巧教你如何快速使用Struts 2。目的是为了帮助读者掌握Struts2框架...
Actions S900 S700 等固件烧录工具,居于windows平台烧录
- name : Cache multiple paths uses : actions/cache@v2 with : path : | ~/cache !~/cache/exclude key : ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} 使用zstd压缩为 Linux 和 macOS 运行程序提高性能并...
-- 定义包管理配置的action 继承struts-default.xml中的配置 --> <package name="actions" extends="struts-default"> <!-- 定义Action(login.action) --> <action name="login" class="mypack.UserAction"> <!...
Playwright GitHub动作 设置GitHub Actions以使用在Chromium,WebKit和Firefox上运行跨浏览器测试。用法在运行测试之前,将uses: microsoft/playwright-github-action@v1到GitHub工作流定义中。 on : push : ...
工作机会 具有Struts2和Hibernate框架的JavaEE中的JobPortal。 Struts2 ... POJO forms and POJO actions - Struts2 has done away with the Action Forms that were an integral part of the Stru
原始SaveAction插件在idea更新到2023.1版本后会报错无法使用,所以有人修复了,源码放在https://github.com/fishermans/intellij-plugin-save-actions,在根目录调用脚本gradlew.bat build后构建,会在根目录下build...