How to put two param-values in one context-param in Spring?

江枫思渺然 提交于 2020-01-15 23:01:49

问题


Problem: I have two contextConfigLocation parameters, one with @Configuration classes for spring-social-facebook and one with xml-file for app:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>com.communicator.core.social.facebook.config</param-value>
</context-param>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/root-context.xml</param-value>
</context-param>

Both of them use one param-name, and I don't know how to fix it.


回答1:


You will be try this

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/root-context.xml,
        com.communicator.core.social.facebook.config
    </param-value>
</context-param>



回答2:


You can use white space to separate each parameter within <param-value> like this.

<context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/resources/spring/*.xml /WEB-INF/resources/module/*.xml /WEB-INF/resources/function/*.xml /WEB-INF/resources/bean/*.xml</param-value>
</context-param>



回答3:


After test all answers, none works for me. I found the solution in this post JSF2 how to specify more than one custom element library in web.xml file

<param-value>com.communicator.core.social.facebook.config;/WEB-INF/root-context.xml</param-value>



回答4:


Servlet spec says that you can have only one value for any context parameter. So, you are left with going with delimited list only.

<context-param>
  <param-name>Hosts</param-name>
  <param-value>ex1.com,ex2.com,.....</param-value>
</context-param>


来源:https://stackoverflow.com/questions/16860016/how-to-put-two-param-values-in-one-context-param-in-spring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!