0

I am working on a project using Struts 1.3 from what I can tell, given that this is at the top of the struts-config-default.xml file:

<!DOCTYPE struts-config PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" 
    "http://struts.apache.org/dtds/struts-config_1_3.dtd">

Is there any way to go about mapping a wildcard for an action forward to a jsp file? I have tried all sorts of wildcard variations:

<action path="/hello/candy" type="com.officedepot.globalweb.framework.action.ForwardDisplayAction">
        <forward name="success" path="/WEB-INF/jsp/candyStore.jsp" />
    </action>

I have a single page application that gets loaded in the 'candyStore.jsp' so i would like all and any URIs after /hello/candy to route to the same JSP. (eg. www.site.com/hello/candy/pageOne, www.site.com/hello/candy/33/jellybean, www.site.com/hello/candy/test all should forward to the jsp candyStore)

Is this at all possible using Struts 1.3 or should I be writing all the possible routes :(

Thanks!

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
penguinsource
  • 1,120
  • 3
  • 16
  • 40

2 Answers2

0

In your action file

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


        //Perform any code here like error 404.
        return mapping.findForward("unspecified");
    }

In your struts action path in config file

<forward name="unspecified" path="/candyStore.jsp"/>
Farhan Qasim
  • 990
  • 5
  • 18
  • If it does not solve what you meant, please comment and i'll delete the answer. I could not have posted in the comments because of a long answer. Or else I would've. – Farhan Qasim Jun 23 '18 at 13:14
0

About 30 seconds on Google:

https://dzone.com/tutorials/java/struts/struts-example/struts-wildcards-in-action-mapping-example.html

<action-mappings>
  <action path="/*Action" type="com.vaannila.reports.{1}Action" name="{1}Form">
    <forward name="success" path="/{1}.jsp" />
  </action>
</action-mappings>

You would not require the wildcard in the forward's path.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302