java - Cannot access to local webpage in Spring MVC -


i started learn 'introduction spring mvc' course pluralsight. when trying access http://localhost:8080/fitnesstracker/greeting.html http status 404. have access localhost:8080/fitnesstracker shows index.jsp. in tutorials works fine i'm confused because did same way.

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" 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_2_5.xsd">  <servlet>     <servlet-name>fittrackerservlet</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <init-param>         <param-name>contextconfiglocation</param-name>         <param-value>/web-inf/config/servlet-config.xml</param-value>     </init-param> </servlet>  <servlet-mapping>     <servlet-name>fittrackerservlet</servlet-name>     <url-pattern>*.html</url-pattern>  </servlet-mapping>  <display-name>archetype created web application</display-name> 

servlet-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:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/mvchttp:  //www.springframework.org/schema/mvc/spring-mvc-3.2.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-3.2.xsd">  <mvc:annotation-driven/> <context:component-scan base-package="com.sergey.controller"/>  <!--  <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix" value="/web-inf/jsp/"/>     <property name="suffix" value=".jsp"/> </bean>  -->   <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"   p:prefix="/web-inf/jsp/" p:suffix=".jsp" /> 

hellocontroller.java

package com.sergey.controller;  import org.springframework.stereotype.controller; import org.springframework.ui.model; import org.springframework.web.bind.annotation.requestmapping;  @controller public class hellocontroller {  @requestmapping(value ="/greeting") public string sayhello (model model) {      model.addattribute("greeting", "hello world");      return "hello"; } } 

hello.jsp

<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en"    "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>insert title here</title> </head> <body> <h1>${greeting}</h1> </body> </html> 

my directory structure:

  • fitnesstracker
    • src
      • main
        • java
          • com/sergey/controller
            • hellocontroller.java
        • resources
        • webapp
          • web-inf
            • config
              • servlet-config.xml
            • jsp
              • hello.jsp
            • web.xml
          • index.jsp
    • pom.xml

dear Сергей Сиротинин,

i have tried same thing. have done removed

<mvc:annotation-driven/> 

tag , jars of version 3.0 replaced 3.2 3.0 in servlet-config.xml

please try same.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -