struts2基本配置
来源:互联网 发布:德比鞋 搭配 知乎 编辑:程序博客网 时间:2024/06/03 12:55
新建项目dynamic web project
项目名为struts
lib下导入.jar包(初学者全部导入(>_<))
web.xml:
配置了一个 Filter, 所有的请求都被过滤给了这个 Filter
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
<web-app>
<display-name>struts</display-name>
<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>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
在src目录下新建一个业务控制Action类,
继承自com.opensymphony.xwork2.ActionSupport,
内容如下:
package com.action;
import com.opensymphony.xwork2.*;
public class HelloWorldAction extends ActionSupport{
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return SUCCESS;
}
}
在src目录下创建一个struts.xml文件:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="basicstruts" namespace="/" extends="struts-default">
<action name="hello" class="com.action.HelloWorldAction">
<result>hello.jsp</result>
</action>
</package>
</struts>
新建hello.jsp测试:
通过访问:
http://localhost:8080/struts/hello
整体思路:
1. 所有的访问都回被web.xml中配置的Struts 的 Filter所拦截
2. 拦截之后,就进入struts的工作流程
3. 访问的地址是/hello,根据struts按照 struts.xml中的配置,服务端跳转到hello.jsp
4. 显示hello.jsp的内容
- struts2-struts2的基本配置
- Struts2总结 - 基本配置
- Struts2基本配置实例
- struts2的基本配置
- Struts2基本的配置
- Struts2的基本配置
- Struts2.2基本配置
- struts2基本配置
- Struts2 基本配置
- Struts2基本配置
- struts2基本配置详解
- struts2入门基本配置
- struts2基本配置
- struts2基本配置
- 3.struts2基本配置
- Struts2的基本配置
- struts2的基本配置
- Struts2 的基本配置
- react学习(ES5和ES6两种写法的对比)
- flexbox-CSS3弹性盒模型flexbox布局完整版教程
- OpenCV 从浮点型数据的视差图中分割并滤除小的斑块
- 【maven&&tomcat】maven自动部署项目到tomcat
- 最短路径:弗洛伊德算法
- struts2基本配置
- binwalk的extract出来的内容
- JavaWeb(7)——Maven学习
- 具名函数和匿名函数
- 链表-leetcode 86 Partition List
- RedMonk 6 月编程语言排行:JS:第一 Java:第二
- JavaWeb学习总结(十一)——使用Cookie进行会话管理
- 史上最详细Linux 虚拟文件系统sysfs之属性文件attribute 整理(二)
- jQuery根据radio来控制texteara