JSTL的taglib的解决方案显示在html页面上

时间:2016-11-24 10:44:58

标签: java spring jsp spring-mvc

当我在Spring中使用JSTL时,视图就像这样显示taglib标签。 enter image description here 这是我的网络配置:

@Configuration
@PropertySources({ @PropertySource(value = "config/application.properties", ignoreResourceNotFound = true) })
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }


    @Bean
    public InternalResourceViewResolver viewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setViewClass(JstlView.class);
        resolver.setPrefix("/WEB-INF/");
        resolver.setSuffix(".jsp");
        return resolver;
    }
}

JSP页面内容:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <h1>${title}</h1>
</body>
</html>

有一些好的解决方案吗?

0 个答案:

没有答案