Created
August 8, 2012 03:37
-
-
Save wataru420/3291837 to your computer and use it in GitHub Desktop.
SpringMVCのFreeMarkerでEnum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomFreeMarkerView extends FreeMarkerView { | |
@Override | |
protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request) throws Exception { | |
super.exposeHelpers(model, request); | |
model.put("enums", BeansWrapper.getDefaultInstance().getEnumModels()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomFreeMarkerViewResolver extends FreeMarkerViewResolver { | |
public CustomFreeMarkerViewResolver() { | |
setViewClass(requiredViewClass()); | |
} | |
@SuppressWarnings("rawtypes") | |
@Override | |
protected Class requiredViewClass() { | |
return CustomFreeMarkerView.class; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
${enums["com.example.MinisiteFieldType"].SEOTEXT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/hoge", method = RequestMethod.GET) | |
public String hoge(Locale locale, Model model) { | |
model.addAttribute("enums", BeansWrapper.getDefaultInstance().getEnumModels() ); | |
return "hoge"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment