MyEclipse中手工配置struts项目的方法及注意细节

本人经常用myeclipse开发工具进行web方面的开发,对于struts项目,以前基本上都用myeclipse自带的工具进行struts的添加。
具体方法步骤如下:
1、 添加struts相关jar包
struts.jar
commons-logging.jar
commons-beanutils.jar
commons-digester.jar
commons-fileupload.jar
commons-validator.jar
jakarta-oro.jar
antlr.jar

将上面这些jar文件拷贝到项目lib目录

2、 添加tld标签库文件
一共有五大标签库文件是:
struts-html.tld
struts-bean.tld
struts-logic.tld
struts-tiles.tld
struts-nested.tld

将以上文件拷贝到你的项目WEB-INF目录

3、添加struts核心配置文件: struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans />
<global-exceptions />
<global-forwards />
<action-mappings />
<message-resources parameter="" />
</struts-config>

4、在web.xml中添加ActionServlet配置 :
struts对于所有的web请求都变成*.do,通过ActionServlet来统一处理。
web.xml文件中加入:
<servlet>
<servlet-name>action</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>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>
/WEB-INF/struts-nested.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>
/WEB-INF/struts-template.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</jsp-config>
到此为止,手工配置struts完成。
:( 但是,当打开struts-config.xml文件时发现出问题了,不能正常打开。抛出如下异常:
org.eclipse.ui.PartInitException: Project newsjq is not configured as a MyEclipse Web-Struts Project. Therefore the MyEclipse Struts Editor may not be used with struts-config.xml. The default XML Editor has been used to open the file instead.
经过对比发现,在此项目的.property缺少了<nature>com.genuitec.eclipse.cross.easystruts.eclipse.easystrutsnature</nature>
对其进行编辑并添加该内容后,一切ok了。 :D
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值