You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by José Antonio Delgado Trujillo <ja...@gmail.com> on 2016/03/24 22:09:41 UTC

Convention plugin

I was trying with the convention plugin and the example in the gitHub.

My actions class are in the package pfc.struts2.annotations.actions so the namespaces of the URL is /annotations/actions.
I put the files jsp in /webapp/content/annotations/actions except the second index.jsp which is in/webapp/content.


All is OK, the url action go well but ...

Now i have a problem with the url to return to index.
There is no index action so i don’t know how to fix the problem without change the package of the actions.

<p><a href="<s:url action="index"/>">Return to home page.</a></p>


I think the best is to use the annotations.


Re: Convention plugin

Posted by Lukasz Lenart <lu...@apache.org>.
2016-03-25 13:39 GMT+01:00 José Antonio Delgado Trujillo <ja...@gmail.com>:
>
>> On 25 Mar 2016, at 06:29, Lukasz Lenart <lu...@apache.org> wrote:
>>
>> I don't really understand what do you mean by that,
>
>
> In the example annotations there are two index.jsp files (one in the /webapp and another in /webapp/content).
>
> The first redirect the response to “index”
> i suppose that this redirect to /webapp/content/index.jsp (but i don’t know why).
>
> In hello-success.jsp and register-success.jsp they are URL action to index.
> There isn’t IndexAction class so i don’t know what the framework will do by default.
> I read the convention plugin documentation i understood the next:
>
> action url -> hello
> action class -> */actions/HelloAction.class
> (result=input), response -> /webapp/content/hello-input.jsp
>
> But what happens if the framework doesn’t find the action class.

It will try to find an "index" action which is created automatically
by Convention plugin

> In my case i had the action class in the package /pfc/struts2/annotations/actions so i had to use the namespace=/annotations/actions in the url and i put the jsp in /webapp/content/annotations/actions
> The url index in jsp files doesn’t go to /webapp/index.

webapp/index.jsp is threatened as a welcome-page but only by
container, for Convention plugin it will be
webapp/web-inf/content/index.jsp


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Convention plugin

Posted by José Antonio Delgado Trujillo <ja...@gmail.com>.
> On 25 Mar 2016, at 06:29, Lukasz Lenart <lu...@apache.org> wrote:
> 
> I don't really understand what do you mean by that,


In the example annotations there are two index.jsp files (one in the /webapp and another in /webapp/content).

The first redirect the response to “index”
i suppose that this redirect to /webapp/content/index.jsp (but i don’t know why).

In hello-success.jsp and register-success.jsp they are URL action to index.
There isn’t IndexAction class so i don’t know what the framework will do by default.
I read the convention plugin documentation i understood the next:

action url -> hello
action class -> */actions/HelloAction.class
(result=input), response -> /webapp/content/hello-input.jsp

But what happens if the framework doesn’t find the action class.


In my case i had the action class in the package /pfc/struts2/annotations/actions so i had to use the namespace=/annotations/actions in the url and i put the jsp in /webapp/content/annotations/actions
The url index in jsp files doesn’t go to /webapp/index.

Un saludo,
José A



 

Re: Convention plugin

Posted by Lukasz Lenart <lu...@apache.org>.
2016-03-24 22:09 GMT+01:00 José Antonio Delgado Trujillo <ja...@gmail.com>:
> I was trying with the convention plugin and the example in the gitHub.
> Now i have a problem with the url to return to index.
> There is no index action so i don’t know how to fix the problem without change the package of the actions.
>
> <p><a href="<s:url action="index"/>">Return to home page.</a></p>
>
>
> I think the best is to use the annotations.

I don't really understand what do you mean by that, first you can use
"namespace" attribute, next Convention plugin support conventio which
means:

    "Default action and result handling (i.e. /products will try
com.example.actions.Products as well as
com.example.actions.products.Index)"

http://struts.apache.org/docs/convention-plugin.html#ConventionPlugin-Introduction


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org