1、两个配置文件(spring-config-admin.xml和struts-config-admin.xml)如下:
xml 代码
- <!---->xml version="1.0" encoding="UTF-8"?>
- <!---->>
-
- <beans default-autowire="byName" default-lazy-init="true">
- <bean name="/admin/codecatalog" class="com.yahaitt.web.CodecatalogAction"/>
- beans>
-
- <!---->xml version="1.0" encoding="UTF-8" ?>
- <!---->
- "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
- "http://struts.apache.org/dtds/struts-config_1_2.dtd">
- <struts-config>
- <form-beans>
- <form-bean name="codecatalogForm" type="org.apache.struts.validator.LazyValidatorForm"/>
- form-beans>
-
- <action-mappings>
-
- <action path="/admin/*" name="{1}Form" scope="request" parameter="method" validate="false">
- <forward name="list" path="/WEB-INF/pages/admin/{1}List.jsp"/>
- <forward name="edit" path="/WEB-INF/pages/admin/{1}Form.jsp"/>
- <forward name="success" path="/admin/{1}.do?method=list" redirect="true"/>
- action>
- action-mappings>
- struts-config>
-
2、执行的ur:http://localhost:8080/yahaitt/admin/codecatalog.do
对应的jsp页面(/WEB-INF/pages/admin/codecatalogList.jsp)相关代码如下:
xml 代码
- <ec:table items="codecatalogs" var="codecatalog"
- action="${ctx}/codecatalog.do">
- <ec:exportXls fileName="CodecatalogList.xls" tooltip="Export Excel"/>
- <ec:row>
- <ec:column property="rowcount" cell="rowCount" sortable="false" title="序号" width="60"/>
- <ec:column property="name" title="名称" width="100"/>
- <ec:column property="shortname" title="标记" width="100"/>
- <ec:column property="null" title="Edit" width="40" sortable="false" viewsAllowed="html">
- <a href="codecatalog.do?method=edit&id=${codecatalog.id}">Edita>
- ec:column>
- <ec:column property="null" title="Remove" width="40" sortable="false" viewsAllowed="html">
- <a href="codecatalog.do?method=delete&id=${codecatalog.id}">Deletea>
- ec:column>
- ec:row>
- ec:table>
-
3、当点击“Edit”时执行了org.springside.core.web.StrutsEntityAction.java中的edit函数如下:
java 代码
- public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
-
- saveToken(request);
- T object = null;
-
-
- if (request.getParameter(idName) != null) {
- object = doGetEntity(form, request);
- if (object == null) {
- saveError(request, "entity.missing");
- return mapping.findForward(LIST);
- }
- } else {
- try {
- object = entityClass.newInstance();
- } catch (InstantiationException e) {
- log.error(e);
- } catch (IllegalAccessException e) {
- log.error(e);
- }
- }
-
- initForm(form, request, object);
- refrenceData(request);
- return mapping.findForward(EDIT);
-
-
- }
-
这个函数能够执行,说明/admin/codecatalog.do配置成功的,断点跟踪,在执行完mapping.findForward(EDIT);时却报错:
Cannot retrieve mapping for action /codecatalog
也就是最后又去找/codecatalog这个配置去了,但是我没有用这个配置,很不明白的是为什么到了最后mapping.findForward(EDIT);时却要去找/codecatalog?
具体的代码和相关的文件在附件里,希望能得到指点,谢谢,该问题已经困惑我两天了。