java - Basic Spring Web MVC Application using annotation -


my basic spring mvc web application doesn't work. created simple spring web maven project , deleted unnecessary code simplify it. then, added controller implementation , annotated in book have read recently. deployed sample application book , app have created. sample app works - mine not. when try acces url ...localhost.../app-name/start/basic/show tomcat server shows 404 error. there's 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 trying solve problem, implemented in sample app don't know why fails.

my traces, when choose "run on server" , have dployed 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' 'org.eclipse.jst.jee.server:app' did not find 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: apr based apache tomcat native library allows optimal performance in production environments not found on 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 shared selector 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 shared selector 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 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 solve problem creating spring mvc project instead of simple spring web maven project. works, now.

according log

your app not deploy.i got clue log

info: deploying

when read info: deploying

it not app "/app"


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -