java - Spring MVC 1 to 1 mapping of a URL to .HTML without exposing path -


i using spring 4.1.5 boot 1.2 on webservice not serve jsps. don't want add jsp servlet want serve single canary page shows in prettier html type format information provided @ /manage/health endpoint.

i have file in webapp/canary/canary.html want serve url: www.mywebservice.com:9343/canary, that, not canary.html

i tried doing this:

@configuration public class canaryconfiguration extends webmvcconfigureradapter {      @override     public void addresourcehandlers(resourcehandlerregistry registry) {         registry.addresourcehandler("/canary")                 .addresourcelocations("/canary/canary.html");     } } 

that doesn't work however.

it expecting handler provide file name. in otherwords location should like: /canary/

and handler like: /canary/**

with that, url www.mywebservice.com:9343/canary/canary.html work charm.

however, want url resolve www.mywebservice.com:9343/canary webapp/canary/canary.html without me having type html.

this easy in jsp servlet because can set suffix ect...

i looked @ resourceresolver didn't make sense me how link current configuration.

it looks want:

provides mechanisms resolving incoming request actual resource , obtaining public url path clients should use when requesting resource.

see: resourceresolver documentation

any beneficial.

also aware can put html in resources/static , several other places automatically configured. requires .html typed, not want in case won't work. thanks!

you can use view controllers it. here sample of it. hope helps.

    public class appconfig extends webmvcconfigureradapter {          @override         public void addviewcontrollers(viewcontrollerregistry registry) {             registry.addviewcontroller("/canary").setviewname("/canary/canary.html");         } } 

note: if using tomcat, might have configure jsp servlet server html files.

related post here.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -