struts的开发环境
1111,引入jar文件
222,创建struts的配置文件
<!--package 包的作用和java中类包是非常类似的,
该name属性值可以任意取名,但必须唯一,通过概述可以实现包继承的引用
包的namespace属性用于定义该包的命名空间,命名空间作为访问该包下的Action的路径的一部分
http://localhost:8080/struts/cs/hello.action
-->
<package name="text" extends="struts-default" namespace="/cs">
<!--
action :
name名称:类似于它<url-pattern>helloservlet
classs属性:类似于,<servlet-class> 可以不写 如果不写默认只想ActionSupport的
method:doget dopost add()方法
-->
<action name="hello" class="cn.csdn.hr.action.HelloAction" method="add">
<!-- name可以不写 name="login" 值是返回值 type="dispatcher" 默认类型 -->
<result >../index.jsp</result>
</action>
</package>
<package name="ast" extends="struts-default" namespace="/cs/test">
<action name="hello1" class="cn.csdn.hr.action.HelloAction" method="add">
<result >../../hello.jsp</result>
</action>
</package>
333,在web.html中添加filter过滤器
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>