提交 | 用户 | 时间
|
1ac2bc
|
1 |
/** |
懒 |
2 |
* Copyright 2018-2020 stylefeng & fengshuonan (sn93@qq.com) |
|
3 |
* <p> |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* <p> |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* <p> |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
package cn.stylefeng.guns.config.web; |
|
17 |
|
|
18 |
import cn.stylefeng.guns.base.auth.context.LoginContext; |
|
19 |
import cn.stylefeng.guns.sys.core.beetl.BeetlConfiguration; |
|
20 |
import cn.stylefeng.guns.sys.core.properties.BeetlProperties; |
|
21 |
import org.beetl.core.resource.ClasspathResourceLoader; |
|
22 |
import org.beetl.ext.spring.BeetlSpringViewResolver; |
|
23 |
import org.springframework.beans.factory.annotation.Autowired; |
|
24 |
import org.springframework.context.annotation.Bean; |
|
25 |
import org.springframework.context.annotation.Configuration; |
|
26 |
|
|
27 |
/** |
|
28 |
* web 配置类 |
|
29 |
* |
|
30 |
* @author fengshuonan |
|
31 |
* @date 2016年11月12日 下午5:03:32 |
|
32 |
*/ |
|
33 |
@Configuration |
|
34 |
public class BeetlConfig { |
|
35 |
|
|
36 |
@Autowired |
|
37 |
private BeetlProperties beetlProperties; |
|
38 |
|
|
39 |
/** |
|
40 |
* beetl的配置 |
|
41 |
*/ |
|
42 |
@Bean(initMethod = "init") |
|
43 |
public BeetlConfiguration beetlConfiguration(LoginContext loginContext) { |
|
44 |
BeetlConfiguration beetlConfiguration = new BeetlConfiguration(loginContext); |
|
45 |
beetlConfiguration.setResourceLoader(new ClasspathResourceLoader(BeetlConfig.class.getClassLoader(), beetlProperties.getPrefix())); |
|
46 |
beetlConfiguration.setConfigProperties(beetlProperties.getProperties()); |
|
47 |
return beetlConfiguration; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* beetl的视图解析器 |
|
52 |
*/ |
|
53 |
@Bean |
|
54 |
public BeetlSpringViewResolver beetlViewResolver(LoginContext loginContext) { |
|
55 |
BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver(); |
|
56 |
beetlSpringViewResolver.setConfig(beetlConfiguration(loginContext)); |
|
57 |
beetlSpringViewResolver.setContentType("text/html;charset=UTF-8"); |
|
58 |
beetlSpringViewResolver.setOrder(0); |
|
59 |
return beetlSpringViewResolver; |
|
60 |
} |
|
61 |
} |