【发布时间】:2013-04-18 06:45:57
【问题描述】:
在 web.xml 中
<jsp-config>
<jsp-property-group>
<description> </description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.jsp</url-pattern>
<page-encoding>EUC-KR</page-encoding>
</jsp-property-group>
</jsp-config>
在 JavaConfig 中
public class WebInitializer implements WebApplicationInitializer {
public void onStartup(ServletContext servletContext)
throws ServletException {
// ??
}
}
如何在 JavaConfig 中设置 jsp-config?
【问题讨论】:
-
你可以通过
servletContext.getJspConfigDescriptor().getJspPropertyGroups();返回一个Collection<JspPropertyGroupDescriptor>来访问它,它有一个add(JspPropertyGroupDescriptor)方法。JspPropertyGroupDescriptor是您必须实现的接口。您最好拥有部分 web.xml 和部分 java 配置。
标签: java spring-mvc servlets web.xml