Announcement Announcement Module
No announcement yet.
Application Context Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Application Context

    I m new in spring MVC framework, i m facing some problem , in my web project i declared some bean in applicationContext.xml and declare some values in the variables, that is(applicationContext) loaded properly by contextLoaderListener but when i want to use that variables that values is coming null, means values are not set by application context,

    Kindly tell me what i do for that.

    Thanks & Regards,
    R. Soni

  • #2
    Could you please post your applicationContext ? And please, use [code].


    • #3

      Code for Applicationcontext

      <bean id="book" class="Book" >
      <property name="a" value="10"></property>
      <property name="b" value="20"></property>

      code from the dispatcher servlet

      <bean name="/home.htm"

      code for controller

      public class HomeController implements Controller{

      Book book;
      public ModelAndView handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception {
      return new ModelAndView("home","message",book.add());



      • #4
        Please use [code] as described at

        From what I see, you create a "book" bean, and you create a controller. But you dont inject the "book" bean to your controller in your application context.


        • #5

          Dear Friend,
          As u know i m new to spring, what i want i m describing below.
          1. I have a training-servlet.xml, inside that i put the whole code as u see, now if i set the parameter in the training-servlet.xml, it is working fine, means if i declare book object in the /homecontoller then i got the value.

          2. But in my project all the beans are declared in the applicationContext and in that file all the parameter are set,

          3. Now my problem is that as u suggest that bean is not injecting and i visit that link as u provided. but i could not gotted. can u add some code in my homecontroller by which i m able to get the book parameter values which was set in the applicationcontext.

          Waiting ur response.



          • #6
            The link I gave you is to format the code you post on the forum to make it more readable. Just like I did below :

            <bean name="/home.htm" class="HomeController">
              <property name="book" ref="book"/>
            You should add a setter for book on your controller, and that should be it.