Spring Boot中未呈现JSP

时间:2018-10-23 20:51:19

标签: jsp spring-boot

几个小时以来,我正在阅读有关如何在Spring Boot中呈现JSP页面的说明。 到目前为止,我所做的是改编pom.xm(它包括JSP必需的程序包,它将作为WAR文件部署)和application.properties。 但是没有显示我的login.jsp。如果我在src \ main \ resources中使用旧的login.html(不包含任何JSP),则它可以正常工作。

我将STS Eclipse用于我的项目。

我的包裹结构:

enter image description here

pom.xml

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
<scope>provided</scope>
</dependency>

application.properties

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

主班

@SpringBootApplication
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
public class MatildaApplication {

public static void main(String[] args) {
    SpringApplication.run(MatildaApplication.class, args);
}

@Bean
AuditorAware<String> auditorProvider() {
    return new AuditorAwareImpl();
}
}

SecurityConfig

@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()    .antMatchers("/","/js/**","/css/**","/img/**", "/webjars/**").permitAll()
.antMatchers("/registration/**","/h2_console/**").hasAuthority("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.invalidateHttpSession(true)
.clearAuthentication(true)
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login?logout")
.permitAll()
.and()
.exceptionHandling()
.accessDeniedHandler(accessDeniedHandler);
}

控制器

@Controller
public class MainController {

@GetMapping("/")
public String root() {
    return "index";
}

@RequestMapping("/login")
public String login(Model model) {
    return "login";
}

@GetMapping("/user")
public String userIndex() {
    return "user/index";
}

@GetMapping("/mitarbeiterverwaltung")
public String mitarbeiterverwaltung() {
    return "mitarbeiterverwaltung";
}    
}

也许有人知道我在想什么?

0 个答案:

没有答案