Apache Struts: Unable to recover ActionForward

I'm trying to learn the structure of Apache Struts, and I wrote a small application that deals with a set of classes, but whenever I try to download the application, it just throws out the following exception:

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

My page index.jsplooks like this:

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

Relevant parts of mine struts-config.xml:

<global-forwards>
    <forward name="showLogin" path="/showLogin.do" />
</global-forwards>
<action-mappings>
    <action path="/showLogin" forward="/pages/choose.jsp" />
    <action path="/adminLogin" forward="/pages/adminLogin.jsp" />
</action-mappings>

And finally, the file choose.jsp:

<%@ page import="javax.sql.*"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<h1>Who are you?</h1>
<ul>
    <li><html:link forward="adminLogin">Administrator</html:link></li>
    <li><html:link forward="instructorLogin">Instructor</html:link></li>
    <li><html:link forward="studentLogin">Student</html:link></li>
</ul>
+3
source share
1 answer

I do not do Struts, so do not bind me to it, but the error seems to indicate that it expects <forward name="adminLogin" />somewhere in the config. You might want to have the same for the other two forwards.

+2
source

Source: https://habr.com/ru/post/1748446/


All Articles