java.net.MalformedURLException:无法检索ActionForward

时间:2011-11-21 11:33:34

标签: java-ee struts

我正在尝试学习Apache Struts框架,我编写了一个小型应用程序来进行类注册,但每当我尝试加载我的应用程序时,它只是吐出以下异常:

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot create redirect URL: java.net.MalformedURLException: Cannot retrieve ActionForward named HelloWorld

我的index.jsp页面如下:

<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"% >
<logic:redirect forward="helloWorld"/ >

我的struts-config.xml的相关部分:

<form-beans>
        <form-bean name="HelloWorldForm" type="com.Form.HelloWorldAction" />
</form-beans>

<global-forwards>
</global-forwards>

<action-mappings>
    <action name="HelloWorldForm" path="/helloWorld" type="com.Form.HelloWorldAction">
        <forward name="success" path="/Success.jsp" />
    </action>
</action-mappings>

HelloWorldAction页面如下所示:

public ActionForward execute(ActionMapping mapping, ActionForm form, 
                        HttpServletRequest request, HttpServletResponse response)
                        throws Exception {

    HelloWorldForm Hw = (HelloWorldForm) form;
    Hw.setMessage("Hello World");

    return mapping.findForward("success");

成功页面如下:

<bean:write name="HelloWorldForm" property="message"/ >

2 个答案:

答案 0 :(得分:0)

<logic:redirect forward="HalloWorld"/ >

首先,没有名为HalloWorld的转发,只有helloWorld

其次,bean命名为HalloWorldForm,操作使用HelloWorldForm - 不是问题,但一旦修复了第一个。

答案 1 :(得分:0)

<global-forwards>
        <forward name="helloWorld" path="/helloWorld.do"/>

</global-forwards>