java - How to do Multiple URL Mapping (aliases) in Spring Boot -
in specific
i want multiple url mapping (in other words aliases) in spring boot
in detail
in spring boot application customer controller class has mapped /customer url below want create changeable aliases
@controller @requestmapping(value = "/customer") public class customercontroller{ in normal spring application mapping in xml, can url mapping below.
<bean class="org.springframework.web.servlet.handler.simpleurlhandlermapping"> <property name="mappings"> <props> <prop key="/customer.htm">customercontroller</prop> <prop key="/tester.htm">customercontroller</prop> </props> </property> </bean> <bean id="customercontroller" class="com. ... .controller.customercontroller" /> spring boot, property file configurations helpful in of time autoconfig working under roof.
- is there way can same using property files.
- what best practice follow when doing url mapping in spring boot can change after compilation.
i tired alot find this. @ end ended in community help. please me on this.
if want drive mapping out of prop file, can below
in application.properties, add key value pair
url.mapping : /test/sample on controller can following:
@controller @requestmapping(value = { "${url.mapping}" }) public class customercontroller{ instead of providing in prop file, if provide url.mapping jvm arg, don't have recompile if change value, restart (which hope can do, have not tried myself) should trick.
for multiple mappings, have add 1 per mapping , map in controller below.
@controller @requestmapping(value = { "${url.mapping}","${url.mapping.two}" }) public class customercontroller{
Comments
Post a Comment