Struts2 HelloWorld
2016-02-20 20:23
204 查看
一、在struts的官网下载最新的struts(http://struts.apache.org/),实在不会百度如何下载struts2。
二、在src目录下配置struts.xml配置文件,并在lib下添加struts相应的类库。
三、配置web.xml,添加过滤器。
四、编写Hello.jsp页面
五、启动tomcat服务器,访问http://localhost:8888/Struts2_Introduction/hello.action
或者http://localhost:8888/Struts2_Introduction/hello
六、浏览器显示:Hello Struts2
注意:使用以上配置,当修改struts.xml中action name 以后,必须重启服务器才能访问到jsp页面。
或者在struts.xml中加入一句:
七、访问流程
二、在src目录下配置struts.xml配置文件,并在lib下添加struts相应的类库。
<pre name="code" class="html" style="font-size: 18px;"><struts>
<package name="default" namespace="/" extends="struts-default"> <action name="hello"> <result> /Hello.jsp </result> </action> </package> </struts>
三、配置web.xml,添加过滤器。
<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>
四、编写Hello.jsp页面
<body> Hello Struts2 <br> </body>
五、启动tomcat服务器,访问http://localhost:8888/Struts2_Introduction/hello.action
或者http://localhost:8888/Struts2_Introduction/hello
六、浏览器显示:Hello Struts2
注意:使用以上配置,当修改struts.xml中action name 以后,必须重启服务器才能访问到jsp页面。
或者在struts.xml中加入一句:
<constant name="struts.devMode" value="true" />问题解决。
七、访问流程
相关文章推荐
- java继承,抽象类
- Java 集合系列05之 LinkedList详细介绍(源码解析)和使用示例
- Java 容器
- Spring MVC 中的 forward 和 redirect 的简单理解
- Struts2之result的配置
- (新手向)spring-boot Gradle installation
- Struts2之Action的基本配置
- Struts2之访问ServletAPI
- Struts2之入门
- LEEDCODE 13 Roman to Integer (JAVA题解)
- EGit with eclipse to clone project from GitHub(Step by step)
- Java-Map测试-学生选课
- Java 排名第一的4个理由
- Java-Set测试-学生选课
- Java数据类型
- Java学习笔记2016.2.20 包装类、数组
- Java-List测试-学生选课
- Java线程-隋唐演义大戏
- Java线程相关
- Exception in thread "main" java.lang.NoClassDefFoundError: xxx (wrong name:xxx)