Search code examples
javapathforwardstruts1

Struts 1 forwards path with parameters


I'm trying to make an action in struts 1 (app of work). I'm at present translating from an old framework to struts 1 (half of the app is in this framework and the other in struts 1), but I cant find the right way to do this translation. My idea is that don't touch code and make it only by "conf-files", in this case "struts-config.xml"

I have the following case that I need to translate, say:

Action class: com.MyApp.TestClass 
Action name: Consulta parameter: dispath 
Forward 1: /login.do 
Forward 2: /signup.do?dispath=register 
Forward 3: /signup.do?dispath=register&addReferal=true

With this case and the signup case:

<action path="/signup" type="com.MyApp.Signup"
            name="SignupForm" scope="request" validate="false"
             parameter="dispatch" />

In the forward 1 I have no problem, there is not a parameter. In the forward 2 I have no problem, there is 1 parameter, dispatch (declared in the action /singup) In the forward 3 I have problems, there are 2 parameters, dispath and other that I need.

The problem occurs only if I do this with conf-file, if I do with java, setting the path directly like

ActionForward a = new ActionForward();
a.setPath("/signup.do?dispath=register&addReferal=true");
action.addForward(a);

This works without errors and like I want, but with conf-file this throws:

15:38:56,742 ERROR [Digester] Parse Fatal Error at line 1067 column 94: La referencia a la entidad "addReferal" debe terminar con el delimitador ';'.
org.xml.sax.SAXParseException: La referencia a la entidad "addReferal" debe terminar con el delimitador ';'.
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.apache.commons.digester.Digester.parse(Digester.java:1572)
        at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:1006)
        at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:955)
        at org.apache.struts.action.ActionServlet.init(ActionServlet.java:470)
        at javax.servlet.GenericServlet.init(GenericServlet.java:212)
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4069)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4362)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:732)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:599)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
        at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.apache.catalina.core.StandardContext.init(StandardContext.java:5263)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:599)
        at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
        at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java:295)
        at org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:108)
        at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
        at org.jboss.web.WebModule.startModule(WebModule.java:83)
        at org.jboss.web.WebModule.startService(WebModule.java:61)

And much more.

Sorry for my bad English, and thank for any idea!

PD: This was an example that represent exactly the problem.


Solution

  • Replace an & with a ; in:

    a.setPath("/signup.do?dispath=register**&**addReferal=true");