1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.shiro.samples.spring.config;
20
21 import org.springframework.context.annotation.Bean;
22 import org.springframework.context.annotation.ComponentScan;
23 import org.springframework.context.annotation.Configuration;
24 import org.springframework.core.annotation.Order;
25 import org.springframework.web.servlet.ViewResolver;
26 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
27 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
28 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
29 import org.springframework.web.servlet.view.InternalResourceViewResolver;
30 import org.springframework.web.servlet.view.JstlView;
31
32
33
34
35 @Configuration
36 @ComponentScan("org.apache.shiro.samples.spring")
37 @EnableWebMvc
38 public class JspViewsConfig extends WebMvcConfigurerAdapter {
39
40 @Bean
41 @Order(1)
42 public ViewResolver getViewResolver(){
43 InternalResourceViewResolver resolver = new InternalResourceViewResolver();
44 resolver.setViewClass(JstlView.class);
45 resolver.setPrefix("/WEB-INF/resources/");
46 resolver.setSuffix(".jsp");
47 return resolver;
48 }
49
50 @Bean
51 @Order(0)
52 public ViewResolver jnlpViewResolver() {
53 InternalResourceViewResolver resolver = new InternalResourceViewResolver();
54 resolver.setViewClass(JstlView.class);
55 resolver.setPrefix("/WEB-INF/jnlp/");
56 resolver.setSuffix(".jsp");
57 return resolver;
58 }
59
60 @Override
61 public void addResourceHandlers(ResourceHandlerRegistry registry) {
62 registry.addResourceHandler("*.css", "*.png").addResourceLocations("/");
63 registry.addResourceHandler("*.jar", "*.pack").addResourceLocations("/WEB-INF/resources/");
64 }
65 }