This question already has answers here:
EL expressions not evaluated in JSP
(5 answers)
Closed 6 years ago.
My project is to let an end user login and then go to another page to display a message. If the login details are wrong it displays an appropriate error message and gives them another chance to login in. The problem is that the message that is meant to be displayed is not. Instead all that is being displayed is;
Message is: ${message}
index.jsp
<form action="login.html" method="post">
Name: <input type="text" name="name"/>
Password: <input type="password" name="password"/>
<input type="submit" value="submit"/>
</form>
LoginController.java
package com.loginmvc.domain;
#Controller
public class LoginController {
#RequestMapping("/login")
public ModelAndView login(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String name = req.getParameter("name");
String password = req.getParameter("password");
if(password.equals("admin")) {
String message = "Welcome " + name;
return new ModelAndView("profilepage", "message", message);
} else {
return new ModelAndView("errorpage", "message",
"Sorry, the name or password is incorrect.");
}
}
}
web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
spring-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.loginmvc.domain" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
You are using an old descriptor in your web.xml file. This will result in the EL being ignored:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
If you are following a tutorial, I would recommend that you find a newer one. However, in the meantime, updating your web.xml should solve your immediate problem:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
...
</web-app>
Make sure that you are using : this Taglib in your JSP
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
and to print message : <c:if test="${not empty message}">${message}</c:if>
I highly recommend you to use IDE like eclipse or netbeans so that it would be easy to detect taglib errors and warning in your jsp.
Related
I am new to Spring MVC. I know there are many answers to my questions on stackoverflow but unfortunately none of them were helpful to solve mu issue. I am trying to implement simple mvc code but i am not able to identify my mistake: I am getting warning: "No mapping found for HTTP request with URI [/SpringMVCDemo/add] in DispatcherServlet with name 'sachin'"
here is index.jsp
<html>
<body>
<form action="add">
<input type="text" name="t1" /> <input type="text" name="t2" />
<input type="submit"/>
</form>
</body>
</html>
My web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>sachin</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sachin</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
My controller where I have used #Controller and #RequestMapping annotation
package com.sachin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class AddController {
#RequestMapping("/add")
public void add() {
System.out.println("I am in AddController");
}
}
My sachin-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd ">
<ctx:annotation-config></ctx:annotation-config>
<ctx:component-scan base-package="com.sachin.*"></ctx:component-scan>
</beans>
Any suggestions are welcome.
Project link
I am doing a spring web-mvc app using maven and tomcat server. So the problem is after clicking on the link of the index.jsp, it is not redirecting to welcome.jsp.
controller class
package com.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
public class controller {
#RequestMapping("/welcome")
public String redirect()
{
return "welcome";
} }
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance..."
version="4.0">
<display-name>CrunchifySpringMVCTutorial</display-name>
<servlet>
<servlet-name>crunchify</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>crunchify</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping></web-app>
index.jsp
<!DOCTYPE html >
<html><head><title>Spring MVC Tutorial Series by Crunchify.com</title>
<h3><a href="welcome">Click here to See Welcome Message... /></h3>
</div></body></html>
Welcome.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "ht
<html><head>
<title>Spring MVC Tutorial by Crunchify - Hello World Spring MVC
Example</title></head><body>
Spring MCV Tutorial by Crunchify.
Click <a href="https://crunchify.com/category/java-tutorials/"
target="_blank">here</a> for all Java and <a
href='https://crunchify.com/category/spring-mvc/'
target='_blank'>here</a>
for all Spring MVC, Web Development examples.<br>
</div></body></html>
crunchify-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=..."
<mvc:annotation-driven />
<context:component-scan
base-package="com.controller" />
<mvc:default-servlet-handler />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/JSP/"></property>
<property name="suffix" value=".jsp"></property>
</bean> </beans>
This is my directory structure. i am not getting how to go to welcome.jsp.
Can someone help me?? Why it is not redirecting to the welcome.jsp??
Issue is with your index.jsp
<h3><a href="welcome">Click here to See Welcome Message... /></h3>
You are mentioning direct welcome in anchor which wouldn't work here.
Use is like that
use <form action="page2.jsp">
or
submit to a servlet using
<form action="targetServlet">,
and then:
redirect to page2, using response.sendRedirect("page2.jsp")
or
forward to page2, using request.getRequestDispatcher("page2.jsp").forward()
I am trying to mix Spring MVC with Java Server Faces. I have a Spring 3.2 #Controller class, which returns a ModelAndView that is resolved to a JSF view. That view contains a <h:form> tag. The problem that I am having is that, on the rendered HTML, the form action attribute combines the original request URL with the name to resolve the view, creating a strange meaningless URL to which the form is POSTed. What I want is just the view name, without the original request URL.
Here is my controller class (org.my.test.MainController):
#Controller
#RequestMapping("/items")
public class MainController
{
#RequestMapping(value="/{itemId}", method=RequestMethod.GET)
public ModelAndView retrieveItem( #PathVariable long itemId ) {
/* Retrieve item */
ModelAndView mav = new ModelAndView();
mav.addObject ("itemName", "A retrieved item");
mav.addObject ("itemId", itemId);
mav.setViewName ("/items");
return mav;
}
}
Here is my JSF template (/items.xhtml)
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Edit item</title>
</h:head>
<h:body>
<h:form>
<h3>Edit item</h3>
<p>
Item name: <h:inputText name="itemName" value="#{itemName}" />
</p>
<p>
Item id: <h:inputText name="itemId" value="#{itemId}" />
</p>
<p>
<h:commandButton value="Submit" />
</p>
</h:form>
</h:body>
</html>
When I request the page http://localhost:8081/items/12345, what is served is this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Edit item</title></head><body><form id="j_id_6" name="j_id_6" method="post" action="/items/12345/items.xhtml" enctype="application/x-www-form-urlencoded">
<h3>Edit item</h3>
<p>
Item name: <input id="j_id_6:j_id_8" name="j_id_6:j_id_8" type="text" value="A retrieved item" />
</p>
<p>
Item id: <input id="j_id_6:j_id_a" name="j_id_6:j_id_a" type="text" value="12345" />
</p>
<p><input id="j_id_6:j_id_c" name="j_id_6:j_id_c" type="submit" value="Submit" />
</p><input type="hidden" name="j_id_6_SUBMIT" value="1" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="oyc7wGGKZrPGinPPmrv9PmTDy0GBlI3c+pjWpdK0KuY69faJ" /></form></body>
</html>
My problem is the bit that says action="/items/12345/items.xhtml" What I want is action="/items" or action="/items.xhtml"
My question has two parts: why is my setup combining the request URL with the view ID like this, and how do I make it stop?
Here is web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Minimal JSF + Spring test</display-name>
<!-- - Location of the XML file that defines the root application context.
- Applied by ContextLoaderListener. -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/spring/application-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<!-- - Servlet that dispatches request to registered handlers (Controller
implementations). -->
<servlet>
<servlet-name>ui</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/ui-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ui</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Just here so the JSF implementation can initialize -->
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
Here is Spring config ui-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:faces="http://www.springframework.org/schema/faces"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:component-scan base-package="org.my.test" />
<mvc:annotation-driven />
<bean id="faceletsViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
<property name="prefix" value="" />
<property name="suffix" value=".xhtml" />
</bean>
</beans>
Here is main Spring config application-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:faces="http://www.springframework.org/schema/faces"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:component-scan base-package="org.my.test" />
</beans>
And here is faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
This is all running in embedded Jetty 9.0.4. I have tried two different JSF implementations, Apache My-Faces 2.1.11 and Mojarra 2.2.1, both with the same effect. Spring version is 3.2.3.
Changing the url-mapping in web.xml from "/" to "/*" corrected the problem.
Everything is in fact behaving according to the Servlet spec (Java Servlet Specification Version 3.0 Rev a, Section 12.2, page 116):
A string beginning with a / character and ending with a /* suffix is used for path mapping.
...
A string containing only the / character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
(Thank you to this post on Coderanch: http://www.coderanch.com/t/366340/Servlets/java/servlet-mapping-url-pattern)
(Java Servlet 3.0 spec available at http://download.oracle.com/otndocs/jcp/servlet-3.0-mrel-eval-oth-JSpec/)
I am trying to learn spring mvc and facing a problem (which seems to be a common one). I have searched a lot of solutions but nothing is helping me out...
My web.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Spring Hello World</display-name>
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>chatbooster</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>chatbooster</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
My chatbooster-servlet.xml is :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>
When I try to run hello.jsp, the error is the requested resource is not available.
Hello.jsp:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#taglib prefix="i" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html>
<head>
<title>Home</title>
</head>
<body>
<h1>Hello World!</h1>
<hr/>
<form action="hi">
Name: <input type="text" name="name"> <input type="submit" value="Submit">
</form>
</body>
</html>
HelloWorldController.ava
#Controller
public class HelloWorldController {
#RequestMapping("/")
public String hello() {
return "hello";
}
#RequestMapping(value = "/hi", method = RequestMethod.GET)
public String hi(#RequestParam("name") String name, Model model) {
String message = "Hi " + name + "!";
model.addAttribute("message", message);
return "hi";
}
}
Edit1:
The problem is occurring because of tomcat server as my simple html page is also not running and it is throwing the same exception. I am using tomcat server version 7. Can anyone hint me out the cause of this exception?
Tomcat doesn't know about hello.jsp since it is inside WEB-INF.
Change
<welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
to
<welcome-file-list>
<welcome-file>/</welcome-file>
</welcome-file-list>
It will work.
This could be a the case of Hello.jsp. The first letter of Hello.jsp is capitalized yet in your controller you are returning a lower case hello. If you change your controller to return the string "Hello" it should work.
Thank you everyone for your answers. Actually I was able to solve my issue by just changing the location of html and jsp pages from web inf folder to web content folder. I dont know why it worked but pages are being run by the server now.
I am trying to implement dynamic check box list in Spring MVC with annotations. So, I tried this one out:
In home.jsp:
<c:forEach items="${categories}" var="cat">
<tr>
<td><form:checkbox path="catrgo" value="${category}"
label="${cat.categoryId}" /></td>
<td><c:out value="${cat.category}" /></td>
</tr>
</c:forEach>
And In HomeController:
#Controller
#RequestMapping(value = "/home")
public class HomeController {
#RequestMapping(method = RequestMethod.GET)
public String showForm() {
FeedDomain feedDomain = new FeedDomain();
System.out.println("Called");
CategoryService categoryService = new CategoryService();
try {
List<CategoryDomain> categoryDomainList = new ArrayList<CategoryDomain>();
CategoryDomain categoryDomain = new CategoryDomain();
categoryDomain.setCategory("aaa");
categoryDomain.setCategoryId(11111);
System.out.println("Size is " + categoryDomainList.size());
} catch (Exception exception) {
}
return "home";
}
Now I am going to home.jsp from index.jsp using tags but the problem is that showForm method is not getting called. What can be the reason?
I am posting below the complete flow:
Here is welcome.jsp from where I am calling home.jsp
<body>
<a href="home.jsp" class="btn btn-success btn-large disabled">Get
Us Feeds Now</a>
</body>
Now I have simplified home.jsp which is getting rendered:
<body>
<br />
<span class="badge badge-info"><h1>Chat Booster</h1></span>
<div class="leftHeader">
<h1>
<small>Subtext for header</small>
</h1>
</div>
<br></br>
<br></br>
</body>
And home page controller is :
#Controller
#RequestMapping(value = "/home")
public class HomeController {
#RequestMapping(method = RequestMethod.GET)
public String showForm() {
FeedDomain feedDomain = new FeedDomain();
// model.addAttribute("feedDomain", feedDomain);
System.out.println("Called");
CategoryService categoryService = new CategoryService();
return "home";
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>HelloWorldExampleWithSpring3MVCInEclipse</display-name>
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet- class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/app-config.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
app-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="com.controller" />
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views
directory -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
My jsp pages are in webcontent folder only (not in web-inf). Now I will look for the main issue later but first point is showForm() method is not being called as sysouts are not priting anything at console. If I make home.jsp as default page of the application, then the method is called but not through the given approach. Can anyone comment on this?
Your link is incorrect, you need to call the controller action not the jsp:
<body>
<c:url var="homeLink" value="/home"/>
Get Us Feeds Now
</body>