You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by developer researcher <ja...@gmail.com> on 2019/01/26 04:05:36 UTC

strange error when migrating to convention plugin - Struts 2.5.20

I am doing migration tests to convention plugin using a project generated
with the archetype "struts2-archetype-blank"

After migrating the actions from struts.xml using the @Action annotation, I
could observe the following:

The line (in a JSP): <link href="<s:url value="*/css/examplecss*"/>"
rel="stylesheet" type="text/css"/> generates the following error:

ERROR Dispatcher Could not find action or result: /blank/css/examplecss
There is no Action mapped for namespace [/css] and action name [examplecss]
associated with context path [/blank]. - [unknown location]

The question is, why does struts look for an action in a reference to a css
file? I'm not sure if it's a problem of "struts2-archetype-blank" or the
IDE (Eclipse JEE 2018-12). The css file does not exist but without
convention plugin (only struts.xml) this strange error does not occur.

I solve the problem by changing the line by <link href="<s:url value="
*/css/examplecss.css*"/>" rel="stylesheet" type="text/css"/> and creating
the css file, but still it is strange that the problem occurs only when
using the convention plugin.

What is the reason for this difference of behavior between the actions
invocation with struts.xml and the convention plugin?

Re: strange error when migrating to convention plugin - Struts 2.5.20

Posted by Lukasz Lenart <lu...@apache.org>.
sob., 26 sty 2019 o 05:13 developer researcher
<ja...@gmail.com> napisał(a):
>
> I am doing migration tests to convention plugin using a project generated
> with the archetype "struts2-archetype-blank"
>
> After migrating the actions from struts.xml using the @Action annotation, I
> could observe the following:
>
> The line (in a JSP): <link href="<s:url value="*/css/examplecss*"/>"
> rel="stylesheet" type="text/css"/> generates the following error:
>
> ERROR Dispatcher Could not find action or result: /blank/css/examplecss
> There is no Action mapped for namespace [/css] and action name [examplecss]
> associated with context path [/blank]. - [unknown location]
>
> The question is, why does struts look for an action in a reference to a css
> file? I'm not sure if it's a problem of "struts2-archetype-blank" or the
> IDE (Eclipse JEE 2018-12). The css file does not exist but without
> convention plugin (only struts.xml) this strange error does not occur.
>
> I solve the problem by changing the line by <link href="<s:url value="
> */css/examplecss.css*"/>" rel="stylesheet" type="text/css"/> and creating
> the css file, but still it is strange that the problem occurs only when
> using the convention plugin.
>
> What is the reason for this difference of behavior between the actions
> invocation with struts.xml and the convention plugin?

Because the Plugin tries to match all the requests, it knows nothing
about CSS and it tries to handle an incoming request. If you want to
exclude a given request define the below constant in struts.xml

<constant name="struts.action.excludePattern" value="/some/content/.*?" />

https://struts.apache.org/core-developers/static-content.html


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