tags:

views:

8

answers:

0

Time for yet another stupid question, adding to a long line of them.

I'm a newbie with Struts 2, having spent years using old 1.X. Struts 2 actions can be roughly equivalent to Struts 1 DispatchActions, simply by adding methods (and defining them in struts.xml).

So, suppose I have this method:

public String create() throws Exception {
    // insert create logic here
}

What I want is to have create() do double duty. If create() is called without being passed any parameters, it returns INPUT (and displays the JSP form page), otherwise it processes the form data and returns SUCCESS (and displays a default page).

The only way I have now is to check and see if any values are in the request, which seems silly to me. If I could say "if I call this via HTTP GET show the form, if I call this via HTTP POST, process then redirect to the default".

Like I said, I'm probably being pretty dumb here, but any help would be appreciated.