java - Tomcat can't load my jsp file - server did not find a current representation -




i'm getting error:

the origin server did not find current representation target resource or not willing disclose 1 exists.

warning [http-nio-8080-exec-6] org.springframework.web.servlet.pagenotfound.nohandlerfound no mapping found http request uri [/] in dispatcherservlet name 'springmvc'

i'm trying use java configuration on simple code. have config class:

 package com.kemal.config;      import org.springframework.context.annotation.componentscan;     import org.springframework.context.annotation.configuration;      @configuration     @componentscan(basepackages = {"com.kemal", "com.kemal.controllers", "com.kemal.services"})     public class javaconfig {      } 

this controller class:

package com.kemal.controllers;  import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping;  @controller public class controller1{      @requestmapping("/")     public string home (){         return "index";     }      @requestmapping("/add")     public string add(){         return "display";     } } 

tomcat deploying application context url "/"

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>springmvc</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <load-on-startup>1</load-on-startup>   </servlet>    <servlet-mapping>     <servlet-name>springmvc</servlet-name>     <url-pattern>/</url-pattern>   </servlet-mapping>  </web-app> 

springmvc-servlet.xml:

<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"    xmlns:context="http://www.springframework.org/schema/c"    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/> <!--<context:component-scan base-package="com"/>-->  <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">     <property name="prefix" value="/web-inf/jsp/"/>     <property name="suffix" value=".jsp"/> </bean> 

my pom.xml:

<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">   <modelversion>4.0.0</modelversion>   <groupid>com.kemal</groupid>   <artifactid>springmvc</artifactid>   <packaging>war</packaging>   <version>1.0-snapshot</version>   <name>springmvc maven webapp</name>   <url>http://maven.apache.org</url>    <dependencies>     <dependency>       <groupid>junit</groupid>       <artifactid>junit</artifactid>       <version>3.8.1</version>       <scope>test</scope>     </dependency>      <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->     <dependency>       <groupid>org.springframework</groupid>       <artifactid>spring-webmvc</artifactid>       <version>4.3.9.release</version>     </dependency>      <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->     <dependency>       <groupid>org.springframework</groupid>       <artifactid>spring-context</artifactid>       <version>4.3.9.release</version>     </dependency>      <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->     <dependency>       <groupid>javax.servlet</groupid>       <artifactid>jstl</artifactid>       <version>1.2</version>     </dependency>     </dependencies>    <build>     <finalname>springmvc</finalname>   </build> </project> 

intellij can connect controller class jsp files referenced in handler methods, think server can't find jsp. missing? can't find solution right now.

project structure , facets: enter image description here enter image description here

project structure

include webmvc annotation @enablewebmvc in configuration class javaconfig. helps scan @controller annotation based classes.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -