Hello Struts2 !
来源:互联网 发布:淘宝客流量是什么意思 编辑:程序博客网 时间:2024/05/15 02:52
新建 JAVA WEB 项目 StrutsTest
拷贝 example Apps 里面的 struts.xml 到 MyEclipse StrutsTest 项目里面的 src 目录下,拷贝 example Apps 里面的 JAR 包到 WebRoot/WEB-INF/lib 目录下,打开 MyEclipse StrutsTest 项目里面的 WebRoot/WEB-INF 目录下的 web.xml ,参照 example Apps 里面的 web.xml 添加 filter 代码:
1: <filter>
2: <filter-name>struts2filter-name>
3: <filter-class>
4: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterfilter-class>
5: filter>
6:
7: <filter-mapping>
8: <filter-name>struts2filter-name>
9: <url-pattern>/*url-pattern>
10: filter-mapping>
在 struts.xml 的
1: <package name="default" namespace="/" extends="struts-default">
2: <action name="hello">
3: <result>
4: /index.jsp
5: result>
6: action>
7: package>
在通过一下代码设定开发者模式:
1: <constant name="struts.devMode" value="true" />
重启服务器后,在浏览器访问 localhost/StrutsTest/hello 即可访问 index.jsp。
访问原理分析:
当我们在浏览器中输入 localhost/StrutsTest/hello ,Tomcat 会根据此 URL 读取 StructsTest 目录中的 web.xml ,此 web.xml 里面配置了过滤器 filter ,此过滤器将所有地址访问都转给了 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter ,这个 StrutsPrepareAndExecuteFilter 类分析 URL ,得到 namespace 为 / ,然后定位到 namespace 为 / 的 package ( 当 namespace 为空的时候能匹配所有 action ),调用里面的 action ,配对到 index.jsp。
有 Hello World 情节的童鞋,可以在修改 index.jsp 内容为 Hello World,或者 Hello Struts2..
- 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实例
- Oracle中case when和decode的用法
- printDocument print
- About App Verifer
- 光照
- 处理ASP.NET Session失效的几个方法
- Hello Struts2 !
- 《GOF设计模式》—迭代器 (ITERATOR)—Delphi源码示例:避免限定于一种特定的列表实现(多态迭代)
- oracle jndi配制问题
- Windows串口通信(上)
- Java Ftp 操作上传与下载
- group by pgsql 与mysql 的区别 (2011.02.18工作日志)
- Asp.net 2.0三层架构的构建与理解
- Myeclipse7.5blue 配置SVN 报错This client is too old to work with working copy
- BS3000J批量 反记账 反审核 的方法