This week's book giveaway is in the XML and Related Technologies forum.
We're giving away four copies of Java XML & JSON and have Jeff Friesen on-line!
See this thread for details.
Win a copy of Java XML & JSON this week in the XML and Related Technologies 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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 ?
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!