1.struts2初体验

来源:互联网 发布:自动发卡密源码 编辑:程序博客网 时间:2024/05/16 12:49

1.导入struts2类库

2.在web.xml 文件中配置FilterDispatcher

<span style="white-space:pre"></span><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern><filter-mapping>

3.编写action类

可以是普通的有execute()函数的类、可以实现action接口、可以继承ActionSupport类

4.编写结果页面

使用struts标签库时,
<%@ taglib prefix=“s” uri="/struts-tags" %>

5.在struts.xml文件中配置action

<!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts><span style="white-space:pre"></span><package name="HelloWorld" extends="struts-default"><span style="white-space:pre"></span><action name="HelloWorld" class="org.sunxin.struts2.ch02.action.HelloWorldAction">            <result name="success">/HelloWorld.jsp</result>        </action><span style="white-space:pre"></span><span style="white-space:pre"></span></package></struts>



0 0
原创粉丝点击