Configure ViewResolver with Spring Boot and annotations gives No mapping found for HTTP request with URI error
You only need to enable the default servlet, this is done by adding the following to your MvcConfiguration
:
@Configuration
@EnableWebMvc
public class MvcConfiguration extends WebMvcConfigurerAdapter{
@Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/");
resolver.setSuffix(".html");
return resolver;
}
@Override
public void configureDefaultServletHandling(
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
Essentially what is happening is Spring does not know how to handle the handling of such content natively(could be a jsp say), and to this configuration is the way to tell it to delegate it to the container.
why im getting this error No mapping found for HTTP request with URI
My problem solved after adding this configuration
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
after adding this configuration white page error stopped but jsp page code started showing as html so added these two dependancies.
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<scope>provided</scope>
this link helps
JSP file not rendering in Spring Boot web application
Spring Boot, Java Config - No mapping found for HTTP request with URI [/...] in DispatcherServlet with name 'dispatcherServlet'
OK! Found the problem.
This link helped me: https://samerabdelkafi.wordpress.com/2014/08/03/spring-mvc-full-java-based-config/
More specifically this configuration:
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
By setting a default handler, I would no longer get a white page but instead the JSP code as html, which clearly tells me that the JSP was being found but not rendered.
So the answer was on this page: JSP file not rendering in Spring Boot web application
I was missing the tomcat-embed-jasper artifact.
No mapping found for HTTP request with URI.... in DispatcherServlet with name
You could try and add an @Controller
annotation on top of your myController Class and
try the following url /<webappname>/my/hello.html
.
This is because org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping
prepends /my to each RequestMapping in the myController class.
Related Topics
Hibernate - Foreign Keys Instead of Entities
Why Shouldn't Java Enum Literals Be Able to Have Generic Type Parameters
Can Add Extra Field(S) to @Manytomany Hibernate Extra Table
Java Raw Type and Generics Interaction
Is There a Way in Java to Convert an Integer to Its Ordinal Name
How to Compile Java to Native Code
How to Serialize Object to CSV File
Convert Java.Util.Hashmap to Scala.Collection.Immutable.Map in Java
Generating Rsa Keys in Pkcs#1 Format in Java
How to Use a Java8 Lambda to Sort a Stream in Reverse Order
Write a File in Utf-8 Using Filewriter (Java)
Static Block VS. Initializer Block in Java
Behaviour of Return Statement in Catch and Finally
Compile Error: Package Javax.Servlet Does Not Exist
Exclude Methods from Code Coverage with Cobertura
Add Multiple Items to an Already Initialized Arraylist in Java