Topic: Action没起作用??

  Print this page

1.Action没起作用?? Copy to clipboard
Posted by: frente
Posted on: 2004-08-10 13:37

刚开始接触struts,做一个简单的页面AddOrg.jsp,Action没有什么实际内容,只是使其forward到一个页面success.jsp.但是不知为什么,在tomcat里可以实现,但在JbuilderX+weblogic8.1中,用struts1.1,部署后,分别显示每个页面都可以,但就是没有成功的forward。请哪位大哥帮帮忙。
struts-config文件:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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>

<form-beans>
<form-bean name="OrgInfoForm" type="rsgl.OrgInfoForm" />
</form-beans>

<global-forwards>
<forward name="input" path="/success.jsp"/>
</global-forwards>

<action-mappings>
<action input="/AddOrg.jsp" name="OrgInfoForm" path="/AddOrg"
type="rsgl.AddOrgAction" validate="true" scope="request" >
<forward name="success" path="/success.jsp" />
<forward name="failed" path="/info.jsp" />
</action>
</action-mappings>

<message-resources
parameter="ApplicationResources"/>
</struts-config>

我的action代码如下:
package rsgl;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.IOException;

public class AddOrgAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws IOException {
// 默认跳转为success
String target =null;
ActionErrors errors = new ActionErrors();

try {
target="success";

}
catch (Exception e) {
System.err.println("Setting target to error");
target = "failed";
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("errors.database.error",
e.getMessage()));

}
// 跳转到相应页面
return (mapping.findForward(target));
}
}

2.Re:Action没起作用?? [Re: frente] Copy to clipboard
Posted by: owlrose
Posted on: 2004-08-12 09:42

debug一下跟进去看看actionforward是什么有没有问题吧
ps.不明白为什么这一段要try?
try {
target="success";

}
catch (Exception e) {
System.err.println("Setting target to error");
target = "failed";
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("errors.database.error",
e.getMessage()));

}

3.Re:Action没起作用?? [Re: frente] Copy to clipboard
Posted by: frente
Posted on: 2004-08-16 14:51

那个try是我去掉了原先一些代码,遗留的。我排除了其它错误引起的不能正确执行。现在原因找到了:
struts-config.cml文件中
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
一段,我原先是分开写的:
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathname" value="/WEB-INF/validator-rules.xml" />
<set-property property="pathname" value="/WEB-INF/validation.xml" />
</plug-in>
改成写在一起就可以了。不知道是不是版本的问题,要看看DTD文件

4.Re:Action没起作用?? [Re: frente] Copy to clipboard
Posted by: frente
Posted on: 2004-08-16 16:17


5.Re:Action没起作用?? [Re: frente] Copy to clipboard
Posted by: frente
Posted on: 2004-08-16 16:51

1.1版本不支持property属性的值pathname,而应该是pathnames。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923