`
chaoting
  • 浏览: 13025 次
社区版块
存档分类
最新评论

Struts 2 Annotations Example 学习

阅读更多
struts2 annotation part1
1)默认情况下 查找的包名中含有:struts,struts2,action or actions
2)Action 名或实现Action接口(通常extends ActionSupport)or以Action结尾
3)映射Url 为驼峰命名的Class名大写字母变小写,各单词间用‘-’连接
4)查找结果页面默认目录为WEB-INF/content
5)默认查找的jsp或其他velocity or freemaker 为url 映射路径 + Action 返回值。如:/welcome-user.action => welcome-user-input.jsp welcome-user-success.jsp

官方参照:http://www.vaannila.com/struts-2/struts-2-example/struts-2-annotation-example-1.html

struts2 annotation part2
1)可通过注解@Action 来改变上述默认的url映射路径
2)可通过WEB-INF/classes/struts.properties 文件中定义 属性改变默认结果页面的存放地址。如:struts.convention.result.path=/results
3)并可以通过@Action 注解中@Result 重新定已映射结果页面来改变Convention plug-in默认选择。
官方参照:http://www.vaannila.com/struts-2/struts-2-example/struts-2-annotations-example-1.html
分享到:
评论

相关推荐

    struts2自定义数据类型转换练习

    Struts2作为一款流行的Java Web框架,其在处理用户输入数据时扮演着重要角色。在实际开发中,我们经常遇到需要将HTTP请求参数转换为Java对象的场景,这就是数据类型转换。本练习主要关注如何在Struts2中实现自定义的...

    struts2文件上传

    同时,别忘了在Action类上添加`@.struts2annotations.Action`注解,并指定执行方法。 ```java public class FileUploadAction { private UploadedFile file; // Getter and Setter methods @Action("upload") ...

    struts2中拦截器的使用

    Struts2是一个强大的Java Web框架,它通过提供一系列的拦截器(Interceptors)来实现灵活的控制...学习如何创建自定义拦截器,以及如何结合不同的拦截器来实现复杂的业务逻辑,对于提升Struts2框架的使用技能至关重要。

    Struts2+JSON 实现AJAX 返回对象和列表

    ### Struts2+JSON 实现 AJAX 返回对象和列表 #### 一、背景介绍 随着Web技术的发展,Ajax(Asynchronous JavaScript and XML)已经成为现代Web应用不可或缺的一部分。它通过后台与前端进行异步数据交换和操作,使...

    struts annotation.ppt

    4. **Type Conversion Annotations**:用于控制Struts2的类型转换,帮助在不同数据类型之间进行自动转换。 Action Annotations的工作原理如下: - Struts2框架首先通过web.xml加载FilterDispatcher,其中包含...

    自定义拦截器的实现以及拦截器的详细配置

    import org.apache.struts2.annotation.Struts2Annotations; import org.apache.struts2.config.annotations.Action; @Action(value = "myAction") @InterceptorRef("myInterceptorStack") // 指定拦截器栈 @Struts...

    Struts2上传所需jar包

    2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable...

    struts1.3.9.zip

    struts1.3.9 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the ...

    struts和hibernate整合的一种方式

    1. **添加依赖**:首先,你需要将Hibernate的相关库文件(如hibernate-core.jar、hibernate-annotations.jar等)放入Web应用的lib目录下,确保Struts和Hibernate能正常工作。 2. **配置Hibernate**:创建`hibernate...

    手动整合Struts1.3 +hibernate3.2+Spring2.5 .txt

    ##### 2. Spring 配置 - **Web.xml 配置**: - 实例化Spring容器: ```xml <param-name>contextConfigLocation <param-value>classpath:beans.xml <listener-class>org.springframework.web.context....

    SSH整合实例,带图版

    而对于Struts,需要struts2-core、struts2-convention-plugin等相关库。 在配置阶段,我们首先在项目中添加Spring支持,通过创建或编辑`applicationContext.xml`文件来定义Spring的IoC容器。在这个文件中,可以配置...

    ssh(三大框架)集成

    ### SSH(Struts2, Spring, Hibernate)三大框架集成详解 #### 一、概述 SSH框架,即Struts2、Spring以及Hibernate三个框架的集成,是Java Web开发中非常流行的一种解决方案。它结合了MVC架构的优势,通过Struts2...

    Compass技术文档

    下面是一个基于SSH(Struts2+Spring+Hibernate)架构的Compass使用示例: 1. **添加依赖库**:在SSH项目基础上添加Compass及相关依赖库,具体包括: - `compass-2.1.2.jar` - `compass-index-patch.jar` - `...

    基于Java的Luncene的compass框架说明使用技术文档.pdf

    SSH指的是Spring、Struts和Hibernate这三大框架的组合。下面介绍如何在SSH环境下使用Compass。 ##### Step 1: 添加依赖库 在SSH项目基础上加入Compass相关jar包,包括但不限于: - `compass-2.1.2.jar`:Compass...

Global site tag (gtag.js) - Google Analytics