
框架-Struts2
大玉莞尔
Playing~~~Fighting~~~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
struts2-Action-1-示例
1. 创建一个带有maven的web项目(可参考如何创建带有maven的web项目) 2. 配置struts.xml<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"原创 2017-04-17 16:00:24 · 442 阅读 · 0 评论 -
Struts-OGNL-3
JSP中<%--注意该项在Struts2.5中不能生效,在struts2.1.6中可以 显示age=8--%><%--http://localhost:8080/hello/ognl/ognl 在User类中重写toString()即可--%><li>访问普通属性的构造方法:</li><s:property value="new dto.User(8)"></s:property><br原创 2017-04-21 16:39:48 · 316 阅读 · 0 评论 -
Struts-OGNL-1
Object-Graph Navigation Language.对象图形化导航语言JSP中<%--http://localhost:8080/hello/ognl/ognl?userName=18--%><li>访问值栈中的action的普通属性:</li><s:property value="userName"></s:property><br><%--http://localhost:80原创 2017-04-20 17:58:04 · 250 阅读 · 0 评论 -
Struts-OGNL-2
jsp中<%--不要忘了配置文件中 <constant name="struts.ognl.allowStaticMethodAccess=false" value="true" /> 参数名字可以在default.properties文件中查--%><li>访问静态方法:</li><s:property value="@com.ognl.OgnlAction@staticMethod()原创 2017-04-20 23:20:04 · 265 阅读 · 0 评论 -
Struts标签-
Control Tags(控制型的标签):ifelseifelseappendgeneratoriteratormergesortsubsetData Tags 1. a 2. action 3. bean 4. date 5. debug 6. i18n 7. include 8. param 9. property 10. push原创 2017-04-20 16:34:52 · 298 阅读 · 0 评论 -
Struts2-ResultType-4-带参数的结果集
场景:在请求的URL中传参,之后参数显示在jsp中如果result的type是forward类型(type=dispatcher/chain),则共享值栈(因为相当于只有一次request请求),不需要在xml中取参数值 xml中<action name="r1" > <result>/resultParam.jsp</result> </action>原创 2017-04-20 14:59:57 · 286 阅读 · 0 评论 -
Struts2-ResultType-3-动态结果集(dynamic_Results)
用在Struts文件中的OGNL表达式,了解即可 “$”用于从ValueStack取值 根据“r”的不同值,跳转到不同页面。public class DynamicAction extends ActionSupport{ private String r; public String execute() throws Exception {// r="/index原创 2017-04-19 15:57:26 · 470 阅读 · 0 评论 -
Struts2-ResultType-2-全局结果集(Global_Results)
<!--http://localhost:8080/hello/global/g1--> <!--展示index.jsp--> <package name="globalResult" namespace="/global" extends="struts-default" > <global-results> <result name="mainp原创 2017-04-19 14:06:06 · 344 阅读 · 0 评论 -
Struts2-ResultType-1-结果类型
前两种常用,前四种了解,其他不常用(后面会仔细研究,用到再说) 1. dispatcher (常用,服务器端跳转,浏览器的访问地址对客户透明) 不配的话,默认是dispatcher(用服务器跳转到结果页面jsp,html,freemarker页面,但不能是action) 2. redirect 客户端跳转,跳转到页面 3. chain 用forward的方式,访问action 4.原创 2017-04-19 10:56:29 · 320 阅读 · 0 评论 -
Struts2-Action-7-系列问题(Action中的web元素访问)
10.action中访问web元素(access web elements) 取得Map类型request,session,application,真实类型HttpServletRequest,HttpSession,ServletContex的引用 1.前三者:依赖于容器( map类型) 2.前三者:IOC // 一般只用这种( map类型) 3.后三者:依赖于容器(真实类型)原创 2017-04-18 17:38:45 · 323 阅读 · 0 评论 -
Struts2-Action-8-系列问题(包含模块配置文件、defaultAction)
11.包含模块配置文件 struts.xml文件中可包含多个struts.xml文件<struts> <include file="struts-1.xml"></include></struts>12.默认action(default action) 效果:访问http://localhost:8080/hello/相当于访问http://localhost:8080/hello原创 2017-04-18 23:28:43 · 307 阅读 · 0 评论 -
Struts2-Action-6-系列问题(乱码问题解决、简单数据校验)
8.乱码问题解决 //在struts2.5中不存在中文问题(使用过滤器)<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> </f原创 2017-04-18 15:09:37 · 313 阅读 · 0 评论 -
Struts2-Action-5-系列问题(接受用户输入(3种方式))
7.接受用户输入(3种方式) 8.乱码问题解决 9.简单数据校验 10.action中访问web元素 11.包含模块配置文件 12.默认action原创 2017-04-18 14:01:56 · 328 阅读 · 0 评论 -
Struts2-Action-4-系列问题(路径、调用Action的自定义方法、通配符)
4.路径设置Struts中的路径问题是根据action的路径而不是通过jsp的路径来确定,所以尽量不要使用相对路径。虽然可以使用redirect方式解决,但redirect方式非必要。解决的办法非常简单,统一使用绝对路径(在jsp中使用request.getContextPath()方式拿到webapp的路径,或者在jsp的head标签中指定”/>)说明:如果当前url路径是http://local原创 2017-04-18 10:25:41 · 677 阅读 · 0 评论 -
Struts2-Action-3-系列问题(作用、namespace、定义自己的action)
Action入门: Struts作用: 把请求和视图分开Namespace namespace决定了action的访问路径,默认为“”,表示可以接收所有路径的action namespace可以写为/,或者/xx,或者/xx/yy,对应的action访问路径为/index.action,/xx/index.action,/xx/yy/index.action namespace最好也用模块原创 2017-04-17 22:20:20 · 505 阅读 · 0 评论 -
Struts-Tags(标签)-1
通用标签propertysetbeanincludeparamdebug控制标签if elseif elseiteratorsubsetUI标签 1.原创 2017-04-21 17:28:59 · 388 阅读 · 0 评论