创建Struts 2简单应用的流程

Step 1 - Create A Basic Java Web Application(创建基本的Java Web应用)

    >=Servlet API 2.4

    >=JSP 2.0

    >=J2ee 5.0

Step 2 - Add index.jsp and Ant Build File(添加index.jsp和ant的构建文件)

Step 3 - Add Struts 2 Jar Files To Class Path(添加Strut2的架包到lib目录)

    找到下载架包然后复制到WEB-INF/lib目录下:

  1. asm-x.x.jar
  2. asm-commons-x.x.jar
  3. asm-tree-x.x.jar
  4. commons-io-X.X.X.jar
  5. commons-lang3-X.X.X.jar
  6. commons-fileupload-X.X.X.jar
  7. freemarker-X.X.X.jar
  8. javassist-X.X.X.jar
  9. ognl-X.X.X.jar
  10. struts2-core-X.X.X.X.jar
  11. xwork-core-X.X.X.jar

Step 4 - Add Logging(添加日志)

    添加log4j-1.2.14.jar http://archive.apache.org/dist/logging/log4j/1.2.14/.架包到WEB-INFO/lib目录下

    安装一个log4j.xml配置文件到src文件目录下(Setup a log4j.xml configuration in the src folde)

    

log4j.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">  <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">      <layout class="org.apache.log4j.PatternLayout">          <param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n"/>      </layout>  </appender>  <!-- specify the logging level for loggers from other libraries -->  <logger name="com.opensymphony"> <level value="DEBUG" /> </logger> <logger name="org.apache.struts2"> <level value="DEBUG" /> </logger> <!-- for all other loggers log only debug and above log messages -->  <root> <priority value="INFO"/> <appender-ref ref="STDOUT" /> </root>  </log4j:configuration> 

Step 5 - Add Struts 2 Servlet Filter(添加Struts 2 Servlet Filter)

Step 6 - Create struts.xml(创建struts.xml)

Step 7 - Build and Run the Application(创建和运行应用)

你可能感兴趣的:(strut2)