title: Spring MVC: How to get context param when instantiate the bean?
body: <p>this is simple question,</p>
  
  <p>how to get servlet context parameter when spring instantiate the bean?</p>
  
  <p>my servlet context xml</p>
  
  <pre><code>&lt;beans:bean id="ApplicationInfo" class="xx.xx.xx.ApplicationInfo"/&gt;
  </code></pre>
  
  <p>In my code</p>
  
  <pre><code>public class ApplicationInfo{
     ApplicationInfo()
     {
        //get context.xml or web.xml parameter
        String xxx = .......;
     }
  }
  </code></pre>
  
  <p>my pom.xml</p>
  
  <pre><code>&lt;org.springframework-version&gt;3.2.11.RELEASE&lt;/org.springframework-version&gt;
  &lt;org.aspectj-version&gt;1.6.9&lt;/org.aspectj-version&gt;
  &lt;org.slf4j-version&gt;1.5.10&lt;/org.slf4j-version&gt;
  &lt;org.springsecurity-version&gt;3.2.5.RELEASE&lt;/org.springsecurity-version&gt;
  &lt;org.springjpa-version&gt;1.1.0.RELEASE&lt;/org.springjpa-version&gt;
  &lt;hibernate.version&gt;4.1.6.Final&lt;/hibernate.version&gt;
  &lt;postgresql.version&gt;9.1-901-1.jdbc4&lt;/postgresql.version&gt;
  &lt;tiles-version&gt;2.2.2&lt;/tiles-version&gt;
  &lt;jackson-json-version&gt;2.1.0&lt;/jackson-json-version&gt;
  </code></pre>
  
  <p>Note: i tried to get servlet context by using @annotation ,however it is nullpointer.</p>
  
  <p><img src="https://i.stack.imgur.com/WqfZ8.png" alt="enter image description here"></p>