用XDocle生成struts-config.xml配置文件,因为工程用到Action是继承DispatchAction,生成配置文件生成不了注释文件内容
大家好,我今天遇到了一个奇怪的问题不知道大家有没有遇到过,我用用XDocle生成struts-config.xml配置文件,因为我的工程用到Action是继承DispatchAction,生成配置文件生成不了注释文件内容
Action文件内容为:
package com.fsh.struts.web.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.fsh.struts.dao.BookDAO;
import com.fsh.struts.model.AddbookForm;
import com.fsh.struts.service.IBookDAO;
/**
* @struts.action name="addbookForm"
* path="/dellbookAction"
* scope="request" validate="true" parameter="action"
*
* @struts.action-forward name="dellbooksuccess"
* path="/Dellbooksuccess.jsp"
*
*/
public class DellbookAction extends DispatchAction {
public ActionForward Dellbook(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
AddbookForm addbookForm = (AddbookForm)form;
IBookDAO bookDAO = new BookDAO();
String[] userIdList = addbookForm.getSelectFlag();
bookDAO.deleteUsers(userIdList);
List userList = bookDAO.findAllBookList();
request.setAttribute("userlist", userList);
return mapping.findForward("listbooksuccess");
}
}
build.properties配置文件的内容为:
product.name=jdbcStrutsOracle
fsh.dir=.
product.db.name=fshStruts
webapp.target=./fsh/build/fsh
module.dir=.
build.dir=${module.dir}/fsh/build
src.dir=${module.dir}/src
dist.dir=${module.dir}/fsh/dist
webapp.dist=${dist.dir}/web
struts-config.back=${module.dir}/web/WEB-INF
struts-config.dir=${module.dir}/web
module.jarpre=fsh
module.name=fsh
module.parent=fsh
app.dir=web/WEB-INF/lib
app.web.dir=${app.dir}/web
lib.dir=web/WEB-INF/lib
xdoclet.dir=web/WEB-INF/lib
xdoclet.force=true
我的Build.xml文件内容为:
<?xml version="1.0" encoding="UTF-8"?>
<project name="jdbcStrutsOracle">
<property file="build.properties"/>
<property name="fsh.dir" value="../fsh"/>
<property name="xdoclet.dir" value="web/WEB-INF/lib"/>
<property name="build.lib.dir" value="web/WEB-INF/lib"/>
<property name="lib.dir" value="web/WEB-INF/lib" />
<property name="app.dir" value="web/WEB-INF/lib"/>
<!--
<path id="compile.classpath">
<fileset dir="${xdoclet.dir}">
<include name="*.jar"/>
</fileset>
</path>
<path id="xdoclet.classpath">
<fileset dir="${xdoclet.dir}">
<include name="*.jar"/>
</fileset>
</path>
-->
<path id="xdoclet.classpath">
<pathelement location="${log4j.jar}" />
<pathelement location="${commons-logging.jar}" />
<pathelement location="${commons-collections.jar}" />
<fileset dir="web/WEB-INF/lib" includes="*.jar" />
</path>
<path id="app.classpath">
<fileset dir="${app.dir}" includes="**/*.jar" />
</path>
<path id="lib.classpath">
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
<path id="compile.classpath">
<path refid="app.classpath" />
<path refid="lib.classpath" />
</path>
<target name="init" description="defines custom tasks">
<!-- Taskdefs -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${ant-contrib.jar}" />
<!-- Ensure that Ant 1.6.2+ is being used -->
<available classname="org.apache.tools.ant.DynamicAttribute" property="ant-1.6.2" />
<fail unless="ant-1.6.2" message="deploy requires Ant 1.6.2" />
</target>
<target name="prepare" depends="init" description="create target directories">
<mkdir dir="${webapp.target}" />
<mkdir dir="${webapp.target}/WEB-INF" />
<mkdir dir="${webapp.dist}" />
<mkdir dir="${build.dir}/web/gen" />
<mkdir dir="${src.dir}/web" />
</target>
<target name="webdoclet" unless="webdoclet.unnecessary" description="Generate web artifacts">
<taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask">
<classpath>
<path refid="xdoclet.classpath" />
<path refid="compile.classpath" />
</classpath>
</taskdef>
<webdoclet destdir="${webapp.target}/WEB-INF" force="${xdoclet.force}" mergedir="${module.dir}/metadata/web" excludedtags="@version,@author" verbose="true">
<fileset dir="${src.dir}"/>
<strutsconfigxml validateXML="true" version="1.1" />
</webdoclet>
<copy todir="${webapp.dist}">
<fileset dir="${struts-config.back}">
<include name="struts-config*.xml" />
</fileset>
</copy>
<copy todir="${struts-config.dir}">
<fileset dir="${webapp.target}" />
</copy>
</target>
</project>
最后生成的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>
<!-- ========== Data Sources Definitions =================================== -->
<!--
Define your Struts data sources in a file called struts-data-sources.xml and place
it in your merge directory.
-->
<!-- ========== Form Bean Definitions =================================== -->
<form-beans>
<form-bean
name="addbookForm"
type="com.fsh.struts.model.AddbookForm"
/>
<!--
If you have non XDoclet forms, define them in a file called struts-forms.xml and
place it in your merge directory.
-->
</form-beans>
<!-- ========== Global Exceptions Definitions =================================== -->
<!--
Define your exceptions in a file called global-exceptions.xml and place
it in your merge directory.
-->
<!-- ========== Global Forward Definitions =================================== -->
<!--
Define your forwards in a file called global-forwards.xml and place
it in your merge directory.
-->
<!-- ========== Action Mapping Definitions =================================== -->
<action-mappings>
<!-- If you have non XDoclet actions, define them in a file called struts-actions.xml and place it in your merge directory. -->
</action-mappings>
<!-- Define your Struts controller in a file called struts-controller.xml and place it in your merge directory. -->
<!-- Define your Struts message-resources in a file called struts-message-resources.xml and place it in your merge directory. -->
<!-- Define your Struts plugins in a file called struts-plugins.xml and place it in your merge directory. -->
</struts-config>
现在问题是,XDocle这个东西好像只认Action和ActionForm如果继续这两个类就可以正常生成配置文件,如果是继承DispatchAction好像就生成不了配置文件,哪位大哥遇到这样的问题,麻烦大家帮忙看一下,哪里出问题了。