建立个Web project,把几个包导入工程的WEB-INF/LIB目录下。
在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>
- <!-- action 必须放在指定的包下定义 -->
- <package name="strutsqs" extends="struts-default">
- <!-- action 实现的类 -->
- <action name="login" class="test.web.action.LoginAction">
- <result name="success">/welcome.jsp</result>
- <result name="error">/error.jsp</result>
- </action>
- <action name="book" class="getBooksAction">
- <result name="success">/welcome.jsp</result>
- <result name="error">/error.jsp</result>
- </action>
- </package>
- </struts>