Hi,
I'm doing a course in Spring and my Spring MVC program prints the standard 'Hello World' message on the
jsp page. Following are the
files concerned:
controller.HelloWorldController.java
--------------------------------------------------
Dispatcher
servlet config file: dispatcher-servlet.xml
-------------------------------------------------------------------------
Entry point for application:index.jsp
--------------------------------------------------
helloworld.jsp
---------------------
web.xml
-------------
and successfully displays the 'Hello World' message on
http://localhost:8080/FirstWebAppUsingSpringMVC/helloworld.htm
I was curious if Spring beans could be accessed from the jsp (googled and did some research on the web in this regard) and was
surprised that they indeed could be done (as provided by Spring designers in the form of exposedContextBeanNames and
exposeContextBeansAsAttributes properties of InternalResourceViewResolver).
[sidebar]
Whether business components should be exposed to the view is, I guess, a topic for another
thread. I've initiated this topic as I'm more
concerned with the 'how to do it' for learning purposes.
[/sidebar]
To implement the same,
I modified
controller.HelloWorldController.java
----------------------------------------------------
Dispatcher servlet config file: dispatcher-servlet.xml
-------------------------------------------------------------------------
helloworld.jsp
---------------------
web.xml
-------------
and introduced
service.HelloWorldService.java (Service bean)
-------------------------------------------------------------------
applicationContext.xml
----------------------------------
However, on running the project, the output on
http://localhost:8080/FirstWebAppUsingSpringMVC/helloworld.htm is
Why is the 'Hello World' message not displayed? Where have I gone wrong??.......have been trying to work around this but unable
to find solution.
Much appreciated if the forum members / experts could help in resolving the same.
Thanks,
Sudhir