Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing an appropriate url pattern for Sitemesh to exclude my servlet from its decorators?

I configured my Spring web app with a servlet to serve images at the URL:

/imgsrv?imgid=12345

I also have Sitemesh installed and now when I call this image servlet, I get a decorator exception related to this servlet, which does not need a decorator applied to it.

According to the Sitemesh docs, you can exclude certain URLs from having a decorator applied to them but the syntax is not clear to me.

Which of the following patterns would seem to be most correct to exclude the URL above from being "decorated":

<decorators defaultdir="/WEB-INF/view/decorators">
    <excludes>
        <pattern>/imgsrv*</pattern>
        <pattern>/imgsrv/*</pattern>
        <pattern>/imgsrv**</pattern>
        <pattern>/imgsrv/**</pattern>
        <pattern>/imgsrv*.*</pattern>
        <pattern>/imgsrv/*.*</pattern>
    </excludes>
    <decorator name="main" page="main.jsp">
        <pattern>/*</pattern>
    </decorator>
</decorators>
like image 461
cafe Avatar asked Feb 26 '23 06:02

cafe


1 Answers

I think that this would be enough:

<decorators defaultdir="/WEB-INF/view/decorators">
    <excludes>
        <pattern>/imgsrv</pattern>
    </excludes>
    <decorator name="main" page="main.jsp">
        <pattern>/*</pattern>
    </decorator>
</decorators>

You are mapping directly to a known servlet path. You don't need wildcard to handle the parameters ( as in ?imgid=12345 ).

like image 70
Tomas Narros Avatar answered Apr 07 '23 23:04

Tomas Narros