0

I am pretty new to Spring Boot, and I saw that if I start a Spring Boot project and put an index.html file in the folder src/main/resources/static, then when I open my browser and go to address "localhost:8080", I'll see this file displayed in the browser.

Now, I have another html file (let's call it 'hello.html'), and I also placed it in src/main/resources/static. I wrote the following code:

@Configuration
@Controller
@EnableAutoConfiguration
@ComponentScan
public class TopicController {

@RequestMapping("/hello")
    public String hello() {
        return "hello.html";
    }
}

As you can understand, I want that when I go to localhost:8000/hello, I'll see the display of 'hello.html' file.

However, I get the following error in the console:

javax.servlet.ServletException: Circular view path [hello.html]: would dispatch back to the current handler URL [/hello.html] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

Do you know what I can do so I can get the hello.html file in the browser for accessing "localhost:8080/hello" ?

CrazySynthax
  • 13,662
  • 34
  • 99
  • 183
  • `Check your ViewResolver setup!` Could you add your dispatcher servlet config? Beside that please review how Spring MVC works ! You can't mix `@Configuration` + `@Controller' + `@ComponentScan` together. Take time and study Spring – akuma8 May 06 '17 at 22:09
  • You need to configure an `InternalResourceViewResolver`. See [this answer](http://stackoverflow.com/a/21755562) for details. – manish May 07 '17 at 03:55
  • @akuma8, thanks for your answer. As for studying Spring - I thought that Sprint Boot is a lightweight version of Spring. Do I have to study the full Spring framework in order to know Sprint Boot? – CrazySynthax May 07 '17 at 13:59
  • Spring Boot is a fast mean for starting a spring project, making easy configuration stuffs,and dependecies handling. I really suggest you to learn more about Spring before using Spring Boot, It could help you to understand how really Spring Boot is someway magic. I'll recommand you the book "Spring In Action" by Graig Walls, it's really usefull for beginners. I am still reading it ^^. – akuma8 May 07 '17 at 14:14

0 Answers0