lundi 21 septembre 2015

Spring @RequestMapping("/favicon.ico") does not work when requested from index.html

I used to get mapping not found for favicon.ico so decided to deal with it.

Easiest thing for me was to add an action to a controller method,@RequestMapping("/favicon.ico").

I no longer get these complaints ( although I don't request favicon.ico myself in an html file, I guess teh browser does this automatically ).

When I visit http://localhost:8080/favicon.ico the action gets hit!

I add the following to my html file:

<link href="/favicon.ico" rel="icon" type="image/x-icon" />

But the action never gets hit.

I've also tried

<link href="http://localhost:8080/favicon.ico" rel="icon" type="image/x-icon" />

but action does not get hit.

I suspect this has to do with get/post request something, and when I request it from the browser manually, a get request is made. When from an html file something else, and Spring won't recognize this.

Please do not recommend me doing:

<mvc:resources mapping="/favicon.ico" location="/favicon.ico" />

as I like to do it from my controller as I have some logic there.

Could there be some cache involved?




Aucun commentaire:

Enregistrer un commentaire