Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

The origin server did not find a current representation for the target resource or is not willing to  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,
I am new to SpringMVC and gradle.
Getting error "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

Here is my code .let me know how to resolve this issue.

Homecontroller.java

package springdemo.mvc;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class Homecontroller {

@RequestMapping("/")
public String showpage( ) {
return "main-menu";
}
}


main-menu.jsp

<!DOCTYPE html>
<html>
<body>
<h2> Spring MVC Demo !!! </h2>
</body>
</html>

spring-mvc-demo-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: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.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd">

<!-- Step 3: Add support for component scanning -->
<context:component-scan base-package="springdemo.mvc" />

<!-- Step 4: Add support for conversion, formatting and validation support -->
<mvc:annotation-driven/>

<!-- Step 5: Define Spring MVC view resolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>

</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">

<display-name>spring-mvc-demo</display-name>

<!-- Spring MVC Configs -->

<!-- Step 1: Configure Spring MVC Dispatcher Servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-demo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet -->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

build.gradle

plugins {
id 'java'
id 'war'
}

group = 'springdemo'
version = '0.0.1-SNAPSHOT'


sourceCompatibility = 1.8
targetCompatibility = 1.8

project.ext.tomcatHome = 'H:/Tomcat'
project.ext.tomcatWebapps = "$tomcatHome/webapps"

repositories {
mavenCentral()
}

dependencies {
   implementation 'org.apache.commons:commons-math3:3.6.1'
   implementation 'org.springframework:spring-web:5.0.5.RELEASE'
   implementation 'org.springframework:spring-webmvc:5.1.2.RELEASE'
   implementation 'org.springframework:spring-context:5.1.2.RELEASE'
   implementation 'org.springframework:spring-core:5.1.2.RELEASE'
   implementation 'org.springframework:spring-beans:5.1.2.RELEASE'
   implementation 'org.springframework:spring-aop:5.1.2.RELEASE'
   implementation 'org.springframework:spring-jdbc:5.1.2.RELEASE'
   implementation 'javax.servlet:jstl:1.2'  

   implementation 'com.google.guava:guava:23.0'
compileOnly "javax.servlet:javax.servlet-api:4.0.1"
   testImplementation 'junit:junit:4.12'
}

war {
archiveName = 'spring-mvc-demo.war'
}

task deployToTomcat(type: Copy) {
from war.archivePath
into "$tomcatWebapps"
}

springproject-structure.png
[Thumbnail for springproject-structure.png]
 
sam sundar chandra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can able to run this Spring program in Tomcat server without Gradle. Not sure what i need to change in build.gradle to make this happen.
Can someone guide me on this ?
 
There's a way to do it better - find it. -Edison. A better tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!