How to show values from property file in JSP in a spring MVC app

后端 未结 5 829
孤街浪徒
孤街浪徒 2020-12-04 20:14

I\'m setting my properties in app-servlet.xml with a bean like this:

    

        
5条回答
  •  甜味超标
    2020-12-04 20:58

    In context just do this:

    
    
    

    for creating Properties bean(same as @nkjava.blogspot.com in his answer). But this is not all work need todo.

    Now you need to expose this bean to JSP. There are few way to do this, depends on type of view resolver. There is solution for InternalResourceViewResolver - you need to set "exposeContextBeansAsAttributes" to true and populate "exposedContextBeanNames" with list of required beans.

    For tiles also are solution.

    Than you can simply use this bean in your JSP. Via EL for example:

    ${propertyConfigurer['my.string.from.prop.file']}
    

提交回复
热议问题