平时使用struts是使用xml配置的,学习使用注解
使用maven的,添加依赖包
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.8</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.1.8</version>
</dependency>
package com.mkyong.user.action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import com.opensymphony.xwork2.ActionSupport;
@Namespace("/User")
@ResultPath(value="/")
@Result(name="success",location="pages/login.jsp")
public class LoginAction extends ActionSupport{
}
给某个函数添加,使用如下操作
@Action(value="Welcome", results={
@Result(name="success",location="pages/welcome_user.jsp")
})
public String login() {
return SUCCESS;
}
例子见下面链接:
http://www.mkyong.com/struts2/struts-2-hello-world-annotation-example/
分享到:
相关推荐
struts2 annotation 注解的详细介绍及使用方法
struts2 使用Annotation配置实现的小例子,转载供大家学习使用,里面包括了所需的jar包
参考博文:http://blog.csdn.net/u011638419/article/details/41743049
struts2,json-plugin, 并全注解零配置
struts2-Annotation
马士兵视频里的struts2 hibernate3 spring2.5 annotation 整合 绝对好用 里面还有jar包 部署就可以用
Struts2的“零配置”特性是Struts2的新功能,可能会出现一些小Bug,所以企业开发者请慎重使用该特性, ...如果用的是Annotation的Struts2,就要将struts.xml去掉,否则即使将struts.xml中的内容注销,也会报错;
博文链接:https://flym.iteye.com/blog/174358
通过产生临时文件下载之后,再通过线程删除临时文件
前段时间很困惑的文件下载问题,现贴出代码,希望能帮到需要的人吧
本文档对利用struts2 注解 annotation 实现文件下载作了简单介绍,并有代码为例,希望对学习struts2注解annotation的人有帮助,特别是需要动态传参方面。
NULL 博文链接:https://vincenta.iteye.com/blog/1535330
用注解(annotation)方式配置struts2 (webwork) 中action的拦截器(interceptor)
struts annotation.ppt 欢迎下载
Struts2 Spring Hibernate 框架整合 Annotation Maven project
Struts2中使用annotation实现零配置
NULL 博文链接:https://zhenghuazhi.iteye.com/blog/1467214
Struts2 Spring Hibernate 框架整合 Annotation Maven project.zip
Struts2+Spring2+Hibernate3+Annotation所需JAR包