Struts 2.1.6 搭建环境

来源:互联网 发布:mac读写ntfs破解版 编辑:程序博客网 时间:2024/05/01 01:15

开发环境:
      JDK 1.6 + MyEclipse 7.0 plus + tomcat 6.0.18
Struts2 版本:
      struts-2.1.6
 
版本一、动态Web Project实现
            1、新建Dynamic Web project,新建 Tagert Runtime指向tomcat 6.0.18.
            2、项工程中WebContent下web-inf目录下的lib中加入如下jar文件
                 commons-fileupload-1.2.1.jar
                 commons-io-1.3.2.jar
                 commons-lang-2.3.jar
                 commons-logging-1.0.4.jar
                 freemarker-2.3.13.jar
                 ognl-2.6.11.jar
                 struts2-core-2.1.6.jar
                 xwork-2.1.2.jar
                以上jar文件是struts2框架基本依赖包。
           3、修改web.xml文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
<display-name>struts2helloword</display-name>
<filter>
  <display-name>struts2 hello word</display-name>
  <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>
<welcome-file-list>
  <welcome-file>index.html</welcome-file>
  <welcome-file>index.jsp</welcome-file>
   </welcome-file-list>
</web-app>
          4、在src目录下创建struts.xml文件。内容如下:
<!DOCTYPE struts PUBLIC
         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
         "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml" />
</struts>
         5、在webContent下创建index.html。内容如下:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
        <title>hello fengzhiyin</title> 
  </head>
  <body>
    Hello Fengzhiyin! <br>
  </body>
</html>
        6、发布工程。file --> Expert --> web war发布到tomcat路径下。
        7、启动测试。

原创粉丝点击