-1

I have configured the annotation to return the values as text. But it's giving me the error: could not find action or result.

Console error:

org.apache.struts2.dispatcher.Dispatcher - Could not find action or result
/part!finder.xhtml
No result defined for action action.PartAction and result success

Action:

@Action(value="part!finder", results = {
    @Result(name="SUCCESS", type="stream", params = {"contentType", "text/html", "inputName", "inputStream"}),
    @Result(name="success", type="stream", params = {"contentType", "text/html", "inputName", "inputStream"})
}) 
public String finder() {
  try {
    inputStream = new ByteArrayInputStream(finder1().getBytes());
  }
  catch(Exception e) { }
    return SUCCESS;
  }
}
Roman C
  • 49,761
  • 33
  • 66
  • 176
user2444474
  • 623
  • 8
  • 21
  • 40

2 Answers2

1

Change the action name, that is a value attribute in the @Action annotation to value="part". ! is a special character used to separate action name and method name in the URL. But not in the action mapping. By adding ! in the action name mapping you make your action unreachable to action mapper that is searching for the action config that contains names without !. This char splits the action name and a method name, so it is inappropriate mapping in your action configuration.

BTW, when constructing URL and you have DMI turned on (which is by default is on) then better use a method attribute to url or submit tag and the correct url that maps to your action will be created after the JSP is rendered (result is processed). You could check the HTML outputed to the browser to see the source HTML code for the page. And you might find you action that is mapped to the (not default) method is prefixed by the ! sign. You could explicitly or via tags add the method to the action URL to execute method other than mapped with the action.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • 1
    Thanks Roman. Thats good info.but this not convention plugin here have used codebehind plugin.@Action(value="part", results = { @Result(name="SUCCESS", type="stream", params = {"contentType", "text/html", "inputName", "inputStream"}) }) – user2444474 Jun 19 '13 at 17:22
  • @user2444474 You should edit the question and say that you are using codebehind plugin, however it's deprecated but ppl at least will know about it. It uses different annotations with the same name as convention plugin, different attributes. It's really hard to know. – Roman C Jun 19 '13 at 19:13
0

If you're using DMI, apply @Action at the class level, and let DMI do the rest.

If you're annotating at the action level, declare a unique action name and don't use DMI.

(Or its syntax; it's confusing.)

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