strtus2搭建步骤:
1.拷贝所需jar到WEB工程目录下的lib
2.配置WEB.xml文件,配置过滤器Filter
<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>
3.编写login.jsp:
<form action="login.action" method="post">
<h1>用户登录</h1>
账号:<input type="text" name="userName"/><br/>
密码:<input type="password" name="passWord"><br/>
<input type="submit" value="登录"/>
</form>
4.创建LoginAction类继承ActionSupport类,重写execute()
5.拷贝struts.xml配置文件到src目录下:
<struts>
<!-- 动态方法调用 -->
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<!-- 开发模式 -->
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="com.liu.web.action.LoginAction">
<result name="success">/success.jsp</result>
</action>
</package>