logo
down
shadow

Could not resolve view with name 'forward:/index.html' in servlet with name 'dispatcherServlet'


Could not resolve view with name 'forward:/index.html' in servlet with name 'dispatcherServlet'

By : Mastro Yobo
Date : November 20 2020, 03:01 PM
I wish did fix the issue. You have two conflicting paths registered in the "WebMVCConfig.java".
This tells your app that every request should be forwarded to the "public" classpath folder.
code :
registry.addResourceHandler("/**").addResourceLocations("classpath:/public/");
registry.addViewController("/").setViewName("forward:/index.html");
package com.lapots.breed.hero.journey.web;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer{

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){

        registry.addResourceHandler("/ui/**").addResourceLocations("classpath:/META-INF/resources/ui/");
    }
}
/hero-journey-web
    /src/main
            /java
                  <!-- lemony snippet -->
            /resources
                /public/index.html
                /application.properties


Share : facebook icon twitter icon
I can't find answer that Could not resolve view with name 'index' in servlet with name 'DispatcherServlet'

I can't find answer that Could not resolve view with name 'index' in servlet with name 'DispatcherServlet'


By : Aissam Hidoussi
Date : March 29 2020, 07:55 AM
like below fixes the issue Take a look at the javadoc of ThymeleafViewResolver#setViewNames(String[]). It states
code :
return "index";
*.html
return "index.html";
Spring dispatcher servlet cannot find index.html . No mapping found for HTTP request with URI [] in DispatcherServlet

Spring dispatcher servlet cannot find index.html . No mapping found for HTTP request with URI [] in DispatcherServlet


By : Mark
Date : March 29 2020, 07:55 AM
I hope this helps . I've been trying to get a simple spring mvc webapp working. I've more or less followed this tutorial: http://www.codejava.net/frameworks/spring/spring-mvc-beginner-tutorial-with-spring-tool-suite-ide , I have found a solution.
In servlet context i added:
code :
<resources mapping="/views/**" location="/WEB-INF/views/" />
<!-- Resolves views selected for rendering by @Controllers to .html resources in the /WEB-INF/webcontent/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/views/" />
    <beans:property name="suffix" value=".html" />
</beans:bean>
Could not resolve view with name 'HelloWorld' in servlet with name 'dispatcherServlet'

Could not resolve view with name 'HelloWorld' in servlet with name 'dispatcherServlet'


By : Md Kamrul Hasan
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Spring boot provides plug and play type facilities that is the beauty of spring boot. Same thing is applicable here for serve static content from locations in web application with spring boot. By default spring boot serves static resources from classpath as default property:
code :
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
spring.mvc.static-path-pattern=/**
@EnableAutoConfiguration
public class AddCustomLocations {
    @Bean
    WebMvcConfigurer configurer () {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addResourceHandlers (ResourceHandlerRegistry registry) {
                registry.addResourceHandler("/pages/**").
                          addResourceLocations("classpath:/my-custom-location/");
            }
        };
    }

    public static void main (String[] args) {

        SpringApplication app =
                  new SpringApplication(AddCustomLocations.class);
        app.run(args);
    }
}
spring.mvc.view.prefix=/templates/
spring.mvc.view.suffix=.html
@Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/hello").setViewName("hello");
        registry.addViewController("/test").setViewName("testPage");
    }
Could not resolve view with name 'htmlviews/index.html' in servlet with name 'dispatcher' using javaconfig

Could not resolve view with name 'htmlviews/index.html' in servlet with name 'dispatcher' using javaconfig


By : Li Bin
Date : March 29 2020, 07:55 AM
it should still fix some issue Problem
Spring is trying to find views under your webapp directory. Since you do not have any view resolver, Spring cannot resolve "htmlviews/index.html". In other words, Spring does not know what it is.
Spring Boot: Could not resolve view with name 'index' in servlet with name 'dispatcherServlet'

Spring Boot: Could not resolve view with name 'index' in servlet with name 'dispatcherServlet'


By : Cindy Benns
Date : March 29 2020, 07:55 AM
will help you For me (spring-boot-starter-parent version 2.0.5.RELEASE) it worked changing the path in this way:
src/main/resources/WEB-INF/view/index.html → src/main/resources/META-INF/resources/view/index.html (for some reason it seemed not liking the WEB-INF name and it needed the nested resources directory).
Related Posts Related Posts :
  • Interrupt CompletableFuture with default value
  • Eclipse - Choosing servers in "Run on server" vs setting "Target Runtime"
  • Spring JPA doesn't validate bean on update
  • How is takeWhile different from filter?
  • Spring Scheduled Cron jobs firing at wrong time
  • JFrame window resizing on every compile. Different results every time
  • Kotlin unresolved reference :add after converting from Java code
  • How to use Neo4j APOC method " apoc.export.csv.query(query,file,config)" in Java program
  • Regex to include all spanish characters and number
  • Parsing and Mapping a JSON Object with Dynamic Properties
  • Which approach to building domain objects in Spring MVC is more correct?
  • Java Long Min and Max not exact as mentioned in docs
  • Selenium opens new tab after SendKeys
  • How to sort a large array of ints?
  • FitNessse Test can not find Fixture
  • Including Signed Libraries in Executable JAR with Maven
  • If and Else statement run on second iteration of while loop
  • Change class of disabled tab on change of dropdown value
  • Junit5 @ParameterizedTest How to pass array as one of parameter
  • Text message not being sent to a list of numbers but is sent when just one number is specified
  • Spring mapped servlet not called in jetty-maven-plugin
  • How to pace the consumption of a sqs queue using spring integration
  • Autowiring Not getting disabled using xml configuration
  • Maze solve and shortest path with Java BFS
  • Spinner updating only on user actions
  • Why are Java rules for protected access such as they are?
  • Modify parameter of method by value in annotation aspectJ
  • How to send sensitive data to a Liferay portlet from outside the Liferay portal
  • Does a server connection stay open if created inside a method?
  • JAR manifest Class-Path, use folder instead of jar
  • How to do a bulk update in Firestore
  • ItemArray.checklist.add() not appending string to ArrayList
  • How to move something on screen without other picture staying there
  • SpringBoot : No matching bean found exception
  • Implementing the Clonable interface, but don't have to override the clone() method
  • how can i get this code to choose a random word once from each array to print a sentence?
  • Static class to get connections from connection pool
  • Unable to start Chrome browser with user profile in Selenium
  • How to pass a object to be created as a parameter for a method in Java?
  • How to retry with hystrix
  • Loading key to KeyStore fails on Android Oreo
  • Spring+Velocity unsuccessful attempts to save object
  • Private constructor in Kotlin
  • Jetty:run fails with NoSuchMethodError with Spring 5
  • Cannot upload my Web Applicartion in Jboss7 EAP7 EAP
  • How to load a certificate from "Credential storage"?
  • Call Genexus procedure stub in Java environment
  • JavaFX clipping produces a 'lottery scratch ticket'-Effect
  • Using DateTimeFormatter on january first cause an invalid year value
  • Get all the output from Watson conversation using java
  • Java unable to open main class and jar file
  • How to override @override method from activity into another class
  • Adding Runtime VM parameters to intellij for Java 9
  • Java IBM MQ Client connected but not getting messages from queue
  • Questions of Tomcat SSL configuration
  • Stale JNLP files for <extension> (since Java 9?)
  • Properly set (system) properties in JUnit 5
  • Spring MVC Model within POST Method is empty
  • VSTS buildagent: Java 9
  • java.lang.NumberFormatException: For input string: "id" for Hibernate
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org