Basic Spring Web MVC Application using annotation

My basic Spring MVC web application doesn't work. I created Simple Spring Web Maven Project and deleted unnecessary code to simplify it. Then, I added Controller implementation and annotated it like in book I have read recently. I deployed a sample application from book and an app I have just created. The sample app works properly - mine not. When i try to acces the URL ...localhost.../app-name/start/basic/show Tomcat Server shows 404 Error. There's my code:

BasicController in spring.app package

@Controller @RequestMapping("/basic") public class BasicController{ @RequestMapping("/show") public ModelAndView handleRequest(HttpServletRequest arg0, HttpServletResponse arg1) throws Exception { Map < String, String > modelData = new HashMap < String, String >(); modelData.put("message", "Hello World!"); return new ModelAndView("showMessage", modelData); } }

App/src/main/webapp/WEB-INF/mvc-config.xml file:

<?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" 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"> <mvc:annotation-driven /> <context:component-scan base-package="spring.app"/> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/view/"/> <property name="suffix" value=".jsp"/> </bean> </beans>

App/src/main/webapp/WEB-INF/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"> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/mvc-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/start/*</url-pattern> </servlet-mapping> </web-app>

showMessage.jsp in WEB-INF/view directory:

<!DOCTYPE html> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta charset="utf-8"> <title>Welcome</title> </head> <body> <h2>${message}</h2> </body> </html>

I was trying to solve this problem, but everything is implemented like in sample app so i don't know why it fails.

My traces, when i choose "run on server" and i have dployed only this app:

cze 29, 2015 6:44:27 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:App' did not find a matching property. cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server version: Apache Tomcat/8.0.23 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server built: May 19 2015 14:58:38 UTC cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Server number: 8.0.23.0 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Name: Windows 8.1 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: OS Version: 6.3 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Architecture: amd64 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Java Home: C:\Program Files\Java\jre1.8.0_45 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Version: 1.8.0_45-b15 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: JVM Vendor: Oracle Corporation cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_BASE: C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: CATALINA_HOME: C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:60768 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.base=C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dcatalina.home=C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23 cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dwtp.deploy=C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\wtpwebapps cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Djava.endorsed.dirs=C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\endorsed cze 29, 2015 6:44:27 PM org.apache.catalina.startup.VersionLoggerListener log INFO: Command line argument: -Dfile.encoding=Cp1250 cze 29, 2015 6:44:27 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_45/bin/server;C:/Program Files/Java/jre1.8.0_45/bin;C:/Program Files/Java/jre1.8.0_45/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\xampp\php;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin;C:\Users\Adrian\Desktop\eclipse;;. cze 29, 2015 6:44:27 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-nio-8081"] cze 29, 2015 6:44:28 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read cze 29, 2015 6:44:28 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-nio-8010"] cze 29, 2015 6:44:28 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read cze 29, 2015 6:44:28 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1648 ms cze 29, 2015 6:44:28 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina cze 29, 2015 6:44:28 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/8.0.23 cze 29, 2015 6:44:28 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [125] milliseconds. cze 29, 2015 6:44:28 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\docs cze 29, 2015 6:44:28 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\docs has finished in 63 ms cze 29, 2015 6:44:28 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\examples cze 29, 2015 6:44:29 PM org.apache.catalina.core.ApplicationContext log INFO: ContextListener: contextInitialized() cze 29, 2015 6:44:29 PM org.apache.catalina.core.ApplicationContext log INFO: SessionListener: contextInitialized() cze 29, 2015 6:44:29 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\examples has finished in 962 ms cze 29, 2015 6:44:29 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\host-manager cze 29, 2015 6:44:29 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\host-manager has finished in 78 ms cze 29, 2015 6:44:29 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\manager cze 29, 2015 6:44:30 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\manager has finished in 110 ms cze 29, 2015 6:44:30 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\ROOT cze 29, 2015 6:44:30 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory C:\Users\Adrian\Desktop\apache-tomcat-8.0.23-windows-x64\apache-tomcat-8.0.23\webapps\ROOT has finished in 47 ms cze 29, 2015 6:44:30 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-nio-8081"] cze 29, 2015 6:44:30 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-nio-8010"] cze 29, 2015 6:44:30 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 2149 ms

Ok, Let's say that I solve this problem by creating Spring MVC Project instead of Simple Spring Web Maven Project. Everything works, now.

-------------Problems Reply------------

According to your log

your app does not get deploy.I got a clue from your log

INFO: Deploying

when you read about INFO: Deploying

It does not say anything about your app which is "/App"

Category:java Views:92 Time:2019-03-19

Related post

  • Creation of Data source and JNDI, communication in spring MVC application using annotation 2011-12-13

    I am creating a demo application using Spring mvc 3.0.Now i wants to connect the my application to the data base using "JNDI" and annotations. I am searching on the web,but not find any good example. Hopefully somebody could give me a good link where

  • How to use Ajax JQuery in Spring Web MVC 2009-11-04

    I am using Spring Web MVC for my application. I have 1 dropdown list in my JSP View, coming from following request called savegroup.htm <bean name="/savegroup.htm" class="com.sufalam.mailserver.presentation.web.GroupSaveController"> <propert

  • Return same view controller using ModelAndView of Spring Web MVC 2009-10-29

    I am using Spring Web MVC and Hibernate for developing my application. My login.jsp page has following code : <form:form method="post" commandName="User"> User Name : <form:input path="email"/> Password : <form:input path="password"/

  • Relations in Spring Web MVC (Using Roo) 2011-06-02

    What is the correct way to specify a one-to-many relationship in Spring Web MVC (using Spring Roo)? Example: A Person has a name and an email. A Team has a name. A Person has a membership in a Team, and a Team has zero or more members. The user would

  • Server Side Validation using Spring Web MVC validator class 2009-11-03

    I am developing app using Spring Web MVC, Hibernate.. Now, i have my login page configuration like : <bean name="/uservalidate.htm" class="UserValidateFormController"> <property name="sessionForm" value="true"/> <property name="command

  • How to implement Logout feature using Spring Web Mvc 2009-11-18

    I am new to Spring Web MVC.. Can I get some example or online link that shows me how to implement logout feature using spring web mvc ? I don't want to use the in built feature of spring security (i.e. ACEGI).. Thanks in advance... --------------Solu

  • Spring Web MVC: How to use a ResponseEntity in the view class, not the controller? 2011-09-22

    Using Spring Web MVC, I would like to use a ResponseEntity to send bytes back to the client. For example, I could do this: @RequestMapping(value = "/getMyBytes", method = RequestMethod.GET) public ResponseEntity< byte[] > handleGetMyBytesReques

  • Spring Web MVC: Use same request mapping for request parameter and path variable 2010-04-30

    Good people: is there a way to express that my Spring Web MVC controller method should be matched either by a request handing in a ID as part of the URI path ... @RequestMapping(method=RequestMethod.GET, value="campaigns/{id}") public String getCampa

  • Spring 3 MVC application runs on netbeans with tomcat, struggling with eclipse 2010-02-11

    I am using eclipse, tomcat6 and I have the maven2 eclipse plugin. I have tried with using my own downloaded version of tomcat6 and the built in eclipse tomcat server, both havent' worked for me. The page simply returns a 404 error from tomcat at http

  • Can't force Spring Web MVC 3.0 framework to work 2011-06-18

    I'm building a Web application with Java. Trying to integrate Spring Web MVC 3.0 framework. But I can't even force simply to show the page. I am using NetBeans 7.0 and Tomcat 6.0. This is what I've got: Web.xml <?xml version="1.0" encoding="UTF-8"

  • Is there a maven 2 archetype for spring 3 MVC applications? 2010-05-03

    I'm experimenting with the spring 3 MVC framework. Since i use maven 2 to manage my project, i'm searching for a archetype to create a spring 3 MVC application. --------------Solutions------------- You can use STS (spring tool suite) a new spring MVC

  • Deploying a sample Spring Web MVC project 2011-04-28

    I'm new to Tomcat, Maven and Spring Web MVC (framework v3 to be precise). I was trying to build the example project mvc-basic so that I could deploy the generated WAR file on a test server (not locally) and analyse the effects. When I run Maven in th

  • Embedded Jetty and Spring Web MVC 2011-05-07

    For a pet project I would like to have an embedded Jetty run a Spring Web MVC app. I've used Spring in web containers (where it's easy to tell "where to start") and I've used embedded Jetty without Spring. It feels a bit like the chicken or the egg p

  • Ant and XML-based Spring security integration (without using annotations) 2012-02-14

    I am newbie to Spring .I built a spring MVC application which is XML based and I used JAR files using Spring Framework MVC application step-by-step. Now I have to integrate spring security in it. I found many tutorials for spring security, but all ar

  • Cassini exceptions on medium trust ASP.NET MVC application using Linq-to-SQL 2009-08-02

    I am receiving the following exception trying to browse a medium trust ASP.NET MVC application (using Linq-to-SQL) on Cassini 3.5.0.2: Could not load file or assembly 'Cassini, Version=3.5.0.2, Culture=neutral, PublicKeyToken=da0fefd60d522a7d' or one

  • Help needed for integrating Displaytag with spring web mvc 2009-10-30

    I just wants to know that is it possible to integrate Displaytag with spring web mvc ? If it is possible then can anybody please provide some tutorial or links for that ? Thanks in advance.. --------------Solutions------------- A quick google for "Di

  • DB connection strings in MVC applications using Entity Framework 2010-12-01

    I am working on an MVC application using Entity Framework. After creating an EDMX, I noticed the DB connection string is located in TWO places - an app.config file in my Data class library, and a web.config file in my web application. We want to: rem

  • The IControllerFactory 'Spring.Web.Mvc.SpringControllerFactory' did not return a controller for the name 'Account 2011-01-17

    I am getting problem like "The IControllerFactory 'Spring.Web.Mvc.SpringControllerFactory' did not return a controller for the name 'Account'" . What does this mean????? I am calling Logon method from controller named Account. but when same file is k

  • Spring Web MVC: Simple controller - $-expression doesn't work 2011-03-15

    I'm starting with Spring Web MVC. I have very simple controller and view, but when i open page http://localhost:8080/springonly/spring/hello i get: ${message}, not Hello World Anybody know what is wrong with that ? Why $-expression have not been reco

  • Spring Web MVC - validate individual request params 2011-06-01

    I'm running a webapp in Spring Web MVC 3.0 and I have a number of controller methods whose signatures are roughly as follows: @RequestMapping(value = "/{level1}/{level2}/foo", method = RequestMethod.POST) public ModelAndView createFoo(@PathVariable l

  • Access Spring Web MVC Exception Resolver from Spring Security Context 2011-06-13

    I have a Spring Web MVC configuration with a SimpleMappingExceptionResolver in it to handle some access exceptions: <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:defaultErrorView="uncaughtException">

  • The spring web mvc framework handle the jsp file dispatch as another request 2011-10-17

    I am new to spring web mvc framework,and I use struts 2 before. I create a new dynamic web project using eclipse EE,and add all the jars to the /web-info/lib. The whole hierarchy of the project is like this: SpringMVCTest WEB-INF web.xml example-serv

  • Spring Web MVC error handling for non binded parameters 2011-10-18

    I am using spring web mvc for registering an user. But my User class has a variable of type Website. public class User{ private String email; private WebSite website; } public class WebSite{ private String webSiteUrl; } In my registration form i need

  • Spring MVC CRUD Application using annotation 2010-07-08

    I wanted to learn how to use annotation in Spring MVC using annotation. But apparently the Spring MC Step By Step that is bundled with Spring 2.5 download release uses concrete Controller hierarchy. Hopefully somebody could give me a good link where

  • Spring MVC 3.0 CRUD application using annotation and jdbc template 2011-12-01

    I want to create a new application in Spring MVC, before start it, I want to learn how to use Spring MVC with annotations and JDBC template. I search many blogs and tutorials about that, but they are pretty much confusing as well. Hopefully somebody

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.097 (s). 11 q(s)