Struts2页面配置和访问servlet API】的更多相关文章

一.Struts2页面配置 在struts2中页面可以分为两种,全局页面和局部页面. 1.全局页面: 在一个<package></package>标签内的多个action都要跳转到该页面,则该页面是全局页面. 全局页面的配置:可以在<package></package>标签内使用<global-result></global-result>标签来配置. 注意:该配置只有在该<package>标签内才有效. <stru…
自动装配 1.根据属性的getter和setter获取值  index.jsp <s:form action="hello" method="POST"> 用户名:<s:textfield name="username"/><br> 密码<s:password name="password"/> <s:submit value="登录"/> <…
一.间接访问 public String execute() throws Exception { this.message="hello,this is put into application!"; this.message2="hello,this is put into session!"; this.message3="hello,this is put into request!"; ActionContext ac=ActionCo…
Struts2登录 1. 需要注意:Struts2需要运行在JRE1.5及以上版本 2. 在web.xml配置文件中,配置StrutsPrepareAndExecuteFilter或FilterDispatcher <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFi…
Struts2的起源与背景 在很长的一段时间内,在所有的MVC框架中,Struts1处于绝对的统治地位,无论是从市场的普及范围,还是具体的使用者数量. 其他MVC框架都无 法与其相比,作为一一款优秀的MVC框架.虽然Struts1可以很好地实现将控制与业务逻辑相分离, 但是其自身也存在一定的缺陷,这些缺陷体 现在以下几方面. 1.表现层支持单 Struts1框架只支持JSP作为其表现层使用,而很多的Java应用,在表现层技术选择时并不一定只使用JSP-种技术,如FreeMarker. Veloc…
Struts2登录 1. 需要注意:Struts2需要运行在JRE1.5及以上版本 2. 在web.xml配置文件中,配置StrutsPrepareAndExecuteFilter或FilterDispatcher 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <filter>       <filter-name>struts2</filter-name>       <filter-class>org.apache.struts…
搭建环境: 引入jar包,src下建立struts.xml文件 项目配置文件web.xml. web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:sc…
一.Struts2中的Servlet API 1.1.struts2的Action实现了MVC中C层的作用 针对请求用户显示不同的信息 登录后段保存用户信息 ----session 保存当前在线人数等功能---application 1.2.传统的Servlet API类型 HttpServletRequest HttpSession ServletContext 1.3.Struts2中将传统的Servlet API类型被处理成Map类型 访问更方便 不依赖传统Servlet API 类型--…
© 版权声明:本文为博主原创文章,转载请注明出处 Struts2提供了三种方式去访问Servlet API -ActionContext -实现*Aware接口 -ServletActionContext 实例: 1.项目结构 2.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi…
Struts2中的Action没有与任何Servlet API耦合,,但对于WEB应用的控制器而言,不访问Servlet API几乎是不可能的,例如需要跟踪HTTP Session状态等.Struts2中提供了一个ActionContext类,Struts2的Action可以通过该类来访问Servlet API. ActionContext类中包含的几个常用方法: Object get(Object key):该方法类似于调用HttpServletRequest的getAttribute(Str…