structs2下的第一个helloworld!

简介: <span style="font-family:微软雅黑; font-size:18px">下载安装好structs2</span> <div style="font-family:微软雅黑; font-size:18px">1.创建并配置好web应用程序,使支持structs2:</div> <div style="font-family:微软雅黑; font-size:18px"
下载安装好structs2
1.创建并配置好web应用程序,使支持structs2:
将structs2/lib下的jar文件除了Junit,sprint-test.jar都拷贝到web-inf/lib下面

2.配置web应用的web.xml文件。拦截所有url,使用struct2
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

	<!-- 定义Struts2的核心Filter -->
	<filter>
		<filter-name>struts2</filter-name>
		<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
	</filter>
	<!-- 让Struts2的核心Filter拦截所有请求 -->
	<filter-mapping>
		<filter-name>struts2</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
</web-app>



3.创建一个hello.jsp ,在里面输入helloworld!

4.在src目录下创建一个structs.xml,配置struts下跳转到hello.jsp

<?xml version="1.0" encoding="GBK"?>

<!DOCTYPE struts SYSTEM "http://struts.apache.org/dtds/struts-2.1.7.dtd" PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN">

<!-- 指定Struts 2配置文件的根元素 -->
-<struts> 
<!-- 指定全局国际化资源文件 -->
 <constant value="mess" name="struts.custom.i18n.resources"/> 
<!-- 指定国际化编码所使用的字符集 -->
 <constant value="GBK" name="struts.i18n.encoding"/> 
<!-- 所有的Action定义都应该放在package下 -->
<package name="default" extends="struts-default">
<action name="hello" class=""> 
<!-- 定义逻辑视图和物理资源之间的映射 -->
 <result name="input">/hello.jsp</result> 
</action> 
</package> 
</struts>




好了,这样在浏览器中输入:localhost:8080/web项目名称/hello
就可以看到helloworld!了。
目录
相关文章
|
4月前
|
网络协议 C++
解决MASM32代码汇编出错: error A2181: initializer must be a string or single item
解决MASM32代码汇编出错: error A2181: initializer must be a string or single item
|
4月前
|
JavaScript 前端开发
this指向的几种情况以及js简单实现call、apply、bind___六卿
本文讨论了JavaScript中`this`的指向规则,并提供了`call`、`apply`和`bind`方法的简单实现,用于改变函数的`this`指向。
23 0
this指向的几种情况以及js简单实现call、apply、bind___六卿
|
7月前
|
Dart 开发工具 C++
Dart第一个程序hello,world
Dart第一个程序hello,world
|
7月前
|
Go
go结构体的定义
go结构体的定义
|
8月前
|
编译器 C++ 开发者
【C/C++】C/C++编程——第一个 C++ 程序:HelloWorld
【C/C++】C/C++编程——第一个 C++ 程序:HelloWorld
89 0
|
JSON 开发工具 数据格式
CommonAPI使用例子-HelloWorld
CommonAPI使用例子-HelloWorld
CommonAPI使用例子-HelloWorld
|
Java 开发工具 Windows
三、实现第一个HelloWorld
基于springboot框架实现第一个HelloWorld
88 0
三、实现第一个HelloWorld
|
C++
c++ demo3 结构体01
c++ demo3 结构体01
59 0
|
编译器 C++
Dev-c++中将头文件和头文件函数分离,编译主函数跳出undefined reference to 的问题解决
Dev-c++中将头文件和头文件函数分离,编译主函数跳出undefined reference to 的问题解决
Dev-c++中将头文件和头文件函数分离,编译主函数跳出undefined reference to 的问题解决
【GO】goto结构体
【GO】goto结构体
107 0
【GO】goto结构体