依存1.追加beetl
<依存性>
<のgroupId> com.ibeetl </のgroupId>
<たartifactId> beetlフレームワークスタータ</たartifactId>
<バージョン> 1.1.22.RELEASE </バージョン>
</依存>
2. [追加beetl構成(追加起動クラス)
// beetl配置
@Bean(にinitMethod = "INIT"、NAME = "beetlConfig")
公衆BeetlGroupUtilConfiguration getBeetlGroupUtilConfiguration(){
BeetlGroupUtilConfiguration beetlGroupUtilConfiguration =新しいBeetlGroupUtilConfiguration()。
ResourcePatternResolver patternResolver = ResourcePatternUtils
.getResourcePatternResolver(新DefaultResourceLoader());
{しようと
ClasspathResourceLoader cploder =新ClasspathResourceLoader(
"テンプレート/");
beetlGroupUtilConfiguration.setResourceLoader(cploder)。
beetlGroupUtilConfiguration.setConfigFileResource(patternResolver
.getResource( "クラスパス:beetl.properties"));
beetlGroupUtilConfigurationを返します。
}キャッチ(例外e){
新規のRuntimeException(e)を投げます。
}
}
@Bean(名= "beetlViewResolver")
公衆BeetlSpringViewResolver getBeetlSpringViewResolver(
@Qualifier( "beetlConfig")BeetlGroupUtilConfiguration beetlGroupUtilConfiguration){
BeetlSpringViewResolver beetlSpringViewResolver =新しいBeetlSpringViewResolver()。
beetlSpringViewResolver.setContentType( "text / htmlの;のcharset = UTF-8");
beetlSpringViewResolver.setOrder(0)。
beetlSpringViewResolver.setViewNames( "* htmlの。");
beetlSpringViewResolver.setConfig(beetlGroupUtilConfiguration)。
beetlSpringViewResolverを返します。
}
3. [追加beetl.properties
#デフォルトの区切り文字<%%>に変更@
DELIMITER_STATEMENT_START = @
DELIMITER_STATEMENT_END =
4.テスト
com.zdc.envihy.testをパッケージ化。
輸入org.springframework.web.bind.annotation.RequestMapping。
輸入org.springframework.web.bind.annotation.RestController;
輸入org.springframework.web.servlet.ModelAndView。
/ **
*测试春ブーツ
* /
@RestController
パブリッククラスTestController {
//项目能否运行
@RequestMapping( "/ハロー")
のパブリック文字列のhello(){
リターン"こんにちはworld1"。
}
// beetl配置是否成功
@RequestMapping( "/ testBeetl")
公衆のModelAndView testBeetl(){
のModelAndViewのModelAndView =新規のModelAndView()。
modelAndView.addObject( "試験"、 "ZDC")。
modelAndView.setViewName( "beetlTest.html");
ModelAndViewを返します。
}
}
<! - HTMLファイル - >
<!DOCTYPE HTML>
<HTML LANG = "EN">
<HEAD>
<METAのcharset = "UTF-8">
<タイトル>テストbeetlテンプレート</ TITLE>
</ HEAD>
<BODY>は
、データが返された背景を取得- - >テスト$ {}
</ BODY>
</ HTML>