Hello Struts2
来源:互联网 发布:软考数据库工程师 编辑:程序博客网 时间:2024/05/22 13:12
Struts2框架的概念
是一个典型的MVC框架,人为的把一个软件分为3个层次
M(Model 模型层) V(view 视图层) C(Controller控制层 控制器),提高开发效率。
V(view 视图层) JSP (freemarker velocity)
C(Controller 控制层) Servlet
M(Model 模型层) Service +DAO +entity
A)MVC设计思想的优点?
1.解耦和 有利于代码的维护
2.有利于分工,提高开发效率
3.各司其职(每个层次实现各自的业务)
引入核心jar包
在web.xml配置struts2过滤器
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
实现Action接口
public class FirstStruts2 implements Action{public String execute() throws Exception {//收集数据HttpServletRequest request = ServletActionContext.getRequest();HttpServletResponse response = ServletActionContext.getResponse();HttpSession session = request.getSession();//调用业务System.out.println("Hello Struts2!");//跳转页面return "success";}}
配置配置文件struts.xml
ServletActionContext类的使用
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response =ServletActionContext.getResponse();
HttpSession session = request.getSession();
Struts2访问的另一种方式
I.Localhost:8989/项目名/A
Ii.Localhost:8989/项目名/A.action
- Hello Struts2 !
- hello struts2
- hello struts2
- Hello Struts2
- struts2--Hello struts2练习
- Struts2 Hello World实例
- Struts2 Hello World 实例
- struts2 hello world 搭建
- Struts2 Hello World 实例
- Struts2 Hello World 实例
- Struts2 Hello World 实例
- Struts2的Hello Word
- Struts2入门 Hello world
- 道听途说:第一个struts2程序:hello struts2
- struts2 的第一个程序hello struts2
- JavaWeb框架-Struts2-1-Hello Struts2!
- Struts2入门教程-Hello World
- 笔记:Struts2 Hello World实例
- 例题6-18 雕塑(Sculpture, ACM/ICPC NWERC 2008, UVa12171)
- Jq表单智能校验(Jq查找和事件处理)
- java---InputStream
- 亚马逊要做一款会说话的智能眼镜,但看起来没那么性感
- 互联网商业变现与计算广告(干货+5000字精彩问答)
- Hello Struts2
- 667. Beautiful Arrangement II
- 分页插件PageHelper
- listView加载
- Volley的框架解读七(Request)
- 深入浅出WPF之我见7
- UTC时间字符串转换为本地时间(北京)
- Tablayout+fragment
- EasyJoyStick使用以及两种操作杆 EasyJoyStick的使用方法,简单的不能再简单 Hedgehog Team-》Easy Touch -》Add Easy Touch For C#