现在的位置: 首页 > 综合 > 正文

搭建struts环境

2017年10月20日 ⁄ 综合 ⁄ 共 943字 ⁄ 字号 评论关闭

    首先,    看图:

第一步是安装MyEclipe。然后,下载struts-2.XX-all.zip。解压,在struts-xxxx-all\struts-xxxx\lib下 ,找到上图的jar包,复制到lib下。

第二步是,然后添加一个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>
</struts>

第三步,添加一个修改web.xml使它内容为

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
	xmlns="http://java.sun.com/xml/ns/j2ee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	
    <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>
    
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

运行一下,如果没有报错,证明环境搭建成功!

参考传智博客视频

抱歉!评论已关闭.