前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Struts2.之HelloWorld简单演示

Struts2.之HelloWorld简单演示

作者头像
qubianzhong
发布2018-09-19 12:57:32
2970
发布2018-09-19 12:57:32
举报
文章被收录于专栏:行者常至行者常至行者常至

新建一个web project:hello-struts

这里写图片描述
这里写图片描述

1.拷贝struts的jar包到项目中(apps中的blank项目中可以找到这些jar包)

这里写图片描述
这里写图片描述

2.讲struts2的过滤器拷贝到web.xml中

这里写图片描述
这里写图片描述

3.配置struts2的配置文件(在src目录中创建struts.xml文件)

这里写图片描述
这里写图片描述

4.创建action(action就是一个POJO类)

这里写图片描述
这里写图片描述
  • 4.1 为action编写execute方法
    public String execute(){

        System.out.println("Hello struts.");
        return "success";

    }
  • 4.2 在struts.xml文件中配置action和返回结果集
<action name="hello" class="net.qbzhong.action.HelloAction"
            method="execute">
            <result name="success">/hello.jsp</result>
        </action>

直接运行,进入index.jsp页面

这里写图片描述
这里写图片描述

在地址栏后面加上hello,进入hello.jsp

这里写图片描述
这里写图片描述
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年07月09日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 新建一个web project:hello-struts
    • 1.拷贝struts的jar包到项目中(apps中的blank项目中可以找到这些jar包)
      • 2.讲struts2的过滤器拷贝到web.xml中
        • 3.配置struts2的配置文件(在src目录中创建struts.xml文件)
          • 4.创建action(action就是一个POJO类)
            • 直接运行,进入index.jsp页面
              • 在地址栏后面加上hello,进入hello.jsp
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档