undefinedfix
Sign in

Springboot requests view to be added automatically . VM suffix error

ZerorezColumbia edited in Wed, 28 Sep 2022

The code is such a simple request background request:

/**
 * 定向去首页
 *
 * @return
 */
@RequestMapping("/test")
public String testPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
    return "/resource/pages/test";
}

Background error:

 ResourceManager :unable to find resource '/resource/pages/test.vm' in any resource loader

After checking the information, I said that velcocity was automatically configured, and the view suffix was automatically added to. VM, but I didn't configure velocity: change it as follows application.properties

 spring.velocity.enabled=false
  spring.velocity.checkTemplateLocation=false
  spring:
  mvc:
  view:
  prefix:/
  suffix:.html
@SpringBootApplication(exclude {DataSourceAutoConfiguration.class,VelocityAutoConfiguration.class})
 @ServletComponentScan
 public class WebInitializer extends SpringBootServletInitializer {
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(WebInitializer.class);
  }
}

In springboot, velocity autoconfiguration and spring . velocity . enabled = false spring . velocity . checkTemplateLocation = False has been identified as an expired class ? Is there any good solution ?

Or how to add login permission verification to HTML ?

0 Replies