1

I have a JSP file with form. That form contains a select drop-down menu

<s:select label="Make a selection" headerKey="-1" headerValue="Select Option" list="stuff" name="books" />

Now, to populate the select menu I created a java file to do that. I also created a SelectAction that will populate the menu and made the form's action pointed to the SelectAction

In my .xml file I adjusted it so it contains action for populating Select then redirect to the action that will deal with the form

XML file

<?xml version="1.0" encoding="UTF-8" ?>

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

<struts>
    <package name="example" namespace="/example" extends="struts-default">
        <action name="SelectAction" class="example.SelectAction">
            <result type="redirectAction">
                <param name="ActionName">AddSubmitAction</param>
                <param name="namespace">/example</param>
            </result>
        </action>
        <action name="AddSubmitAction" class="example.AddSubmittAction">
            <result type="chain">
                <result>/example/addOrder.jsp</result>

            </result>
          </action>
    </package>
</struts>

What I am trying to do in the xml is first have the SelectAction (so select menu populates) then redirect it to AddSubmitAction which will take care of the form input.

HOWEVER, this is not working. I get a dispatcher not found error. Is my approach incorrect? Is the redirectAction being misused here?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Shamwow
  • 71
  • 7

2 Answers2

0

Parameter for action name is case sensitive

<param name="actionName">AddSubmitAction</param>
Roman C
  • 49,761
  • 33
  • 66
  • 176
0

Best Way to Populate Your select Tag value is to make prepare method. prepare method is always call first when your action class is called.

So in your one Action class make prepare method:

public void prepare(){ //set your list here }

You can also define prepare method for each method define in your action class: if your method is public String execute(){ }

then your prepare method should be public void prepareExecute(){ And implement Preparable interface in your action class.

For further reading:prepare interceptor

Jay Trivedi
  • 170
  • 1
  • 1
  • 10