1

I have created an action with a method like below:

public class NomenclatureAction extends ActionSupport {

    // ...

    @Actions({
      @Action(value = "ajaxDoStuff",
              results = {
                    @Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
                    @Result(name = ActionSupport.INPUT, location = "fail.jsp") 
              }),
      @Action(value = "index.action",
              results = {
                    @Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
                    @Result(name = ActionSupport.INPUT, location = "fail.jsp") 
              })
    })
    public final String doStuff() {
        // ...
        return ActionSupport.SUCCESS;
    }

}

I want to call the same method doStuff with one of the URLs below:

So far, it works for the first two URLs but not for the last two ones.
What am I missing?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Stephan
  • 41,764
  • 65
  • 238
  • 329

1 Answers1

1

The value attribute should not contain an extension.

@Action(value = "index.action",
  results = {
        @Result(name = ActionSupport.SUCCESS, location = "success.jsp"),
        @Result(name = ActionSupport.INPUT, location = "fail.jsp") 
  })

You might also try http://my-server.com/public/namespace which should be handled by the convention uknown handler, which is enabled by default.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Thanks, it works like charm! Do you know if it's possible to share the results between the two actions without a global result annotation on the class directly? – Stephan Jan 27 '16 at 11:34
  • Results are configured to the action config, and you can't modify it at runtime. Only if you write extensions to convention plugin or use custom provider, or you can just create a result on the fly. – Roman C Jan 27 '16 at 11:41
  • The @Results configuration is the same for both actions. How to not rewrite this configuration two times for readability? – Stephan Jan 27 '16 at 11:45
  • 1
    Unfortunately, you can use `@Results` only on class. But you can use wildcards in the url pattern matcher. – Roman C Jan 27 '16 at 11:50
  • [wildcards in the url pattern matcher](http://stackoverflow.com/a/26747410/573032) – Roman C Jan 27 '16 at 11:58