- 浏览: 7845533 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (2425)
- 软件工程 (75)
- JAVA相关 (662)
- ajax/web相关 (351)
- 数据库相关/oracle (218)
- PHP (147)
- UNIX/LINUX/FREEBSD/solaris (118)
- 音乐探讨 (1)
- 闲话 (11)
- 网络安全等 (21)
- .NET (153)
- ROR和GOG (10)
- [网站分类]4.其他技术区 (181)
- 算法等 (7)
- [随笔分类]SOA (8)
- 收藏区 (71)
- 金融证券 (4)
- [网站分类]5.企业信息化 (3)
- c&c++学习 (1)
- 读书区 (11)
- 其它 (10)
- 收藏夹 (1)
- 设计模式 (1)
- FLEX (14)
- Android (98)
- 软件工程心理学系列 (4)
- HTML5 (6)
- C/C++ (0)
- 数据结构 (0)
- 书评 (3)
- python (17)
- NOSQL (10)
- MYSQL (85)
- java之各类测试 (18)
- nodejs (1)
- JAVA (1)
- neo4j (3)
- VUE (4)
- docker相关 (1)
最新评论
-
xiaobadi:
jacky~~~~~~~~~
推荐两个不错的mybatis GUI生成工具 -
masuweng:
(转)JAVA获得机器码的实现 -
albert0707:
有些扩展名为null
java 7中可以判断文件的contenttype了 -
albert0707:
非常感谢!!!!!!!!!
java 7中可以判断文件的contenttype了 -
zhangle:
https://zhuban.me竹板共享 - 高效便捷的文档 ...
一个不错的网络白板工具
一 struts 2.1中,用convention去代替了code-behind,
convention用法:
1、默认拦截action,actions,struts,struts2包名下面的Action为结尾或者继承ActionSupport的类。
当然也可以改 <constant name="struts.convention.package.locators" value="web"/> VALUE中指定
WEB目录及子目录下Action为结尾或者继承ActionSupport的类
,这样的话,不用再写struts.xml中的配置
比如在地址栏中输入hello.action
则去找com.xxxx.web包下HelloAction.java的对应的action类中的excute方法,
如果是hello!hello.action,则找 HelloAction.java中的hello方法
然后去 WEB-INF\content\hello.jsp 找对应的页面显示。
如果不想设定这个目录,则可以设置:
<constant name="struts.convention.result.path" value="/WEB-INF/jsp/"/>
2 如果访问的名字为 hello-world.action
则访问HelloWorld.action类(去掉-号) WEB-INF\content\hello-world.jsp
<constant name="struts.convention.action.name.separator" value="."/> 则可以改变多个单词之间的分隔符,
这样的话,可以用
hello.world.action去访问,同时web-inf\content\hello.world.jsp要改成相应的.号
3 @action的使用
@Action("/langsin")
public String mth1(){
System.out.println(" mth1 ok");
return SUCCESS;
}
同时在web-inf/jsP中配置langsin.jsp,则访问xxxx/langsin.action,会访问mth1方法,输出mth1 ok
如果有多个方法,多个action的注解,比如:
@Action("/langsin")
public String mth1(){
System.out.println(" mth1 ok");
return SUCCESS;
}
@Action("/iceman")
public String mth2(){
System.out.println(" mth2 ok");
return SUCCESS;
}
则可以xxxx/langsin!mth2.action访问mth2方法,输出System.out.println(" mth2 ok"),注意用的JSP
页为langsin.jsp,而不是用iceman.jsp
同理 xxx/iceman!mth1.action访问mth1方法,输出mth1 ok
4 如果src\com.web一个包,而在com.web下又有一个子目录user,比如src\com.web.user\UserAction.java,
则必须同时在web-inf\jsp\user\user.jsp,
然后访问时,用http://xxxx/user/user.action访问
命名空间:
@Action("/langsin/iceman")
public String mth3(){
System.out.println(" mth3 ok");
return SUCCESS;
}
则web-inf\jsp\langsin\iceman.jsp
5
@Actions({
@Action("/one"),
@Action("/two")
})
public String mth4(){
System.out.println(" mth4 ok");
return SUCCESS;
}
能同时映射多个,
6 返回值的映射
@Action("rs")
public String mth5(){
System.out.println(" mth5 ok");
return "error";
}
访问的是rs_error.jsp(action的名字-返回值的名字)
7 命名空间
@Namespace("/helloworld")
public class HelloWorld extends ActionSupport {
。。。。。
@Action("langsin")
public String mth1(){
System.out.println(" mth1 ok");
return SUCCESS;
}
要用http://xxx/helloworld/langsin.action访问,并且映射的是web-inf\jsp\helloworld目录下的langsin.jsp
而如果 @Action("/langsin"),则覆盖掉namespace了,不需要用namespace
直接http://xxx/langsin.action即可,但访问的是web-inf\jsp下的langsin.jsp
8 拦截器
@InterceptorRefs({
@InterceptorRef("otherInterceptor"),
@InterceptorRef("myInterceptorStack")
})
。。。。。。。。。。。。。。
9 <constant name="struts.convention.action.name.lowercase" value="false"/>
说明JSP用大写映射规则,比如Hello-World.action,映射到Hello-World.jsp ,区分大小写,一般该值取TRUE
convention用法:
1、默认拦截action,actions,struts,struts2包名下面的Action为结尾或者继承ActionSupport的类。
当然也可以改 <constant name="struts.convention.package.locators" value="web"/> VALUE中指定
WEB目录及子目录下Action为结尾或者继承ActionSupport的类
,这样的话,不用再写struts.xml中的配置
比如在地址栏中输入hello.action
则去找com.xxxx.web包下HelloAction.java的对应的action类中的excute方法,
如果是hello!hello.action,则找 HelloAction.java中的hello方法
然后去 WEB-INF\content\hello.jsp 找对应的页面显示。
如果不想设定这个目录,则可以设置:
<constant name="struts.convention.result.path" value="/WEB-INF/jsp/"/>
2 如果访问的名字为 hello-world.action
则访问HelloWorld.action类(去掉-号) WEB-INF\content\hello-world.jsp
<constant name="struts.convention.action.name.separator" value="."/> 则可以改变多个单词之间的分隔符,
这样的话,可以用
hello.world.action去访问,同时web-inf\content\hello.world.jsp要改成相应的.号
3 @action的使用
@Action("/langsin")
public String mth1(){
System.out.println(" mth1 ok");
return SUCCESS;
}
同时在web-inf/jsP中配置langsin.jsp,则访问xxxx/langsin.action,会访问mth1方法,输出mth1 ok
如果有多个方法,多个action的注解,比如:
@Action("/langsin")
public String mth1(){
System.out.println(" mth1 ok");
return SUCCESS;
}
@Action("/iceman")
public String mth2(){
System.out.println(" mth2 ok");
return SUCCESS;
}
则可以xxxx/langsin!mth2.action访问mth2方法,输出System.out.println(" mth2 ok"),注意用的JSP
页为langsin.jsp,而不是用iceman.jsp
同理 xxx/iceman!mth1.action访问mth1方法,输出mth1 ok
4 如果src\com.web一个包,而在com.web下又有一个子目录user,比如src\com.web.user\UserAction.java,
则必须同时在web-inf\jsp\user\user.jsp,
然后访问时,用http://xxxx/user/user.action访问
命名空间:
@Action("/langsin/iceman")
public String mth3(){
System.out.println(" mth3 ok");
return SUCCESS;
}
则web-inf\jsp\langsin\iceman.jsp
5
@Actions({
@Action("/one"),
@Action("/two")
})
public String mth4(){
System.out.println(" mth4 ok");
return SUCCESS;
}
能同时映射多个,
6 返回值的映射
@Action("rs")
public String mth5(){
System.out.println(" mth5 ok");
return "error";
}
访问的是rs_error.jsp(action的名字-返回值的名字)
7 命名空间
@Namespace("/helloworld")
public class HelloWorld extends ActionSupport {
。。。。。
@Action("langsin")
public String mth1(){
System.out.println(" mth1 ok");
return SUCCESS;
}
要用http://xxx/helloworld/langsin.action访问,并且映射的是web-inf\jsp\helloworld目录下的langsin.jsp
而如果 @Action("/langsin"),则覆盖掉namespace了,不需要用namespace
直接http://xxx/langsin.action即可,但访问的是web-inf\jsp下的langsin.jsp
8 拦截器
@InterceptorRefs({
@InterceptorRef("otherInterceptor"),
@InterceptorRef("myInterceptorStack")
})
。。。。。。。。。。。。。。
9 <constant name="struts.convention.action.name.lowercase" value="false"/>
说明JSP用大写映射规则,比如Hello-World.action,映射到Hello-World.jsp ,区分大小写,一般该值取TRUE
发表评论
-
复习:强迫线程顺序执行方式
2019-01-03 23:42 1472方法1: 三个线程,t1,t2,t3,如果一定要按顺序执行, ... -
(转)不错的前后端处理异常的方法
2019-01-02 23:16 1961前言 在 Web 开发中, 我们经常会需要处理各种异常, 这是 ... -
info q的极客时间大咖说等资料下载
2018-08-15 08:40 3408info q的极客时间大咖说等资料下载,还有不少思维导图 链 ... -
CXF 客户端超时时间设置(非Spring配置方式)
2018-07-03 22:38 2173import org.apache.cxf.endpoint. ... -
(转)synchronized关键字画像:正确打开方式
2018-06-14 09:25 443https://mp.weixin.qq.com/s/b3Sx ... -
CountDownLatch的例子
2018-06-13 14:10 627public class StatsDemo { ... -
两道面试题,带你解析Java类加载机制
2018-06-12 16:29 549https://mp.weixin.qq.com/s/YTa0 ... -
Spring中获取request的几种方法,及其线程安全性分析
2018-06-11 09:03 620https://mp.weixin.qq.com/s/KeFJ ... -
内部类小结
2018-06-06 10:25 392https://mp.weixin.qq.com/s/hErv ... -
JVM虚拟机小结1
2018-06-04 20:43 4581 jps -l //列出详细的类名和进程ID 2)jps ... -
windows下自带命令行工具查看CPU资源情况等
2018-06-04 12:53 3037微软提供了不少命令行 ... -
(收藏)深入分析Java的序列化与反序列化
2018-05-30 15:21 551https://mp.weixin.qq.com/s/T2Bn ... -
apache common包中的序列化工具
2018-05-30 09:10 1770什么是序列化 我们的 ... -
JAVA8 JVM的变化: 元空间(Metaspace)
2018-05-24 22:30 902本文将会分享至今为至我收集的关于永久代(Permanent G ... -
(转)服务器性能指标(一)——负载(Load)分析及问题排查
2018-05-21 21:03 1258原创: Hollis Hollis 负载 ... -
(转)对象复用
2018-05-20 15:27 802public class Student { priv ... -
mapreduce中入门中要注意的几点
2018-05-06 08:59 613在 mapreduce中,比如有如下的词: I love b ... -
HDFS的基本操作
2018-05-02 21:47 872-mkdir 在HDFS创建目录 ... -
一个不错的开源工具类,专门用来解析日志头部的,好用
2018-05-02 20:00 703一个不错的开源工具类,专门用来解析日志头部的,好用。 http ... -
介绍个不错的RESTFUL MOCK的工具wiremock
2018-04-27 21:02 1848介绍个不错的RESTFUL MOCK的工具wiremock,地 ...
相关推荐
很详细的struts2框架的添加,配置文件的编写,注解方式,HTTP解耦合,通配符,动态结果读取,有详细的案例。
springmvc框架原理(掌握) 前端控制器、处理器映射器、处理器适配器、视图解析器 springmvc入门程序 目的:对前端控制器、处理器映射器、处理器适配器、视图解析器学习 ...springmvc和struts2的区别
spring 2.5.6 + struts 2.2.1 + hibernate 3.5.5 内有 AOP 的切面、全部的注解的 M V C 结构,之外还在上网上找了一个同学的学习笔记一起打包,感觉好不错!
使用 Spring 可插入的 MVC 架构,从而在使用 Spring 进行 WEB 开发时,可以选择使用 Spring的 Spring MVC 框架或集成其他 MVC 开发框架,如 Struts1(现在一般不用),Struts2 等。SpringMVC 已经成为目前最主流的 MVC...
SpringMVC笔记内容:第一天(SpringMVC的概述、SpringMVC与Struts2优势分析、重要组件、运行原理、SpringMVC环境搭建、@RequestMapping注解详解、字符编码过滤器、传参形式(基本数据类型或String、对象类型、对象....
三、 第三步:再来整合Struts2 41 四、 struts的读常量: 43 第十二课:DTO、VO 43 一、 DTO 43 二、 VO 43 第十二课:SSH整合存在的问题 43 一、 Jsp中访问Session时,Session已经关闭 43 二、 如果不配置事务,...
\contentsline {chapter}{Contents}{2}{section*.1} {1}Java基础}{17}{chapter.1} {1.1}基本语法}{17}{section.1.1} {1.2}数字表达方式}{17}{section.1.2} {1.3}补码}{19}{section.1.3} {1.3.1}总结}{23}{...
方便解耦,简化开发 Spring就是一个大工厂,可以将所有对象创建和依赖关系维护,交给Spring...Spring不排斥各种优秀的开源框架,其内部提供了对各种优秀框架(如:Struts、Hibernate、MyBatis、Quartz等)的直接支持
6、SpringMVC和Struts2的区别 第二天 1、高级参数绑定 a)数组类型的参数绑定 b)List类型的绑定 2、@RequestMapping注解的使用 3、Controller方法返回值 4、SpringMVC中异常处理 5、图片上传处理 6、Json数据交互 7...
三、 第三步:再来整合Struts2 41 四、 struts的读常量: 43 第十二课:DTO、VO 43 一、 DTO 43 二、 VO 43 第十二课:SSH整合存在的问题 43 一、 Jsp中访问Session时,Session已经关闭 43 二、 如果不配置事务,...
Spring的Ioc Spring的AOP , AspectJ Spring的事务管理 , 三大框架的整合 目录 1.1 Spring 框架学习路线:..........................................................................................................
struts2最好别用最新的版本,否则有可能出现XXClassNotFound的情况,下载的压缩包里面有可以参考的xml文件 eclipse跑程序的时候要注意有可能因为页面缓存导致不显示新页面 maven: struts.xml等文件的路径可以参考...