使用eclipse3.4建struts1.X工程

用惯了myeclipse,突然转到了eclipse上一时有点不适应了(新公司不让使用。。。),建了一个struts的工程,竟然花费了两个多小时!唉,我脑子反应有点慢啊!
闲话少说,现在说创建方式:
1.new--->Dynamic web project(这点不像myEclipse方便)---->填写工程名,next--->将webContent改为WebRoot(可以不改,不过习惯了WebRoot不改总觉得怪怪的,呵呵)ok。
2.选择“项目”--->properties--->java builder path---->source:将Default output folder 由strutsTest/bulid/classes改为:strutsTest/WebRoot/WEB-INF/classes
3.选择“项目”--->properties--->Libraries--->Add External JARs...,选择要导入的jar包。OK
注意:此处导入后,有时会不成功,这是就要劳烦您直接把jar包copy入你的lib目录下了。具体原因我还没搞清楚,哪位大虾知道,还望不吝赐教。
后面的事就简单了,写一个Struts的配置文件,然后将其配置到web.xml文件里。ok
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">

<!--Action Servlet Configuration-->
<servlet>
<servlet-name>actionServlet</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<!--Action Servlet Mapping-->
<servlet-mapping>
<servlet-name>actionServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<session-config>
<session-timeout>30</session-timeout>
</session-config>

<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>


struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>

</struts-config>


到此工程搭建完毕,运行一下:
运行:打开tomcat安装目录,找到conf下的server.xml文件,在底部加上
<Context path="/strutsTest" docBase="D:\workspace\strutsTest\WebRoot"/>,ok,然后运行你的项目,ok!
BTW,我安装了tomcat插件的。

你可能会遇到:ERROR - Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:这样的一个问题。此时你可以把你的包手动导入到你的lib目录下就ok了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值