如何在JavaWeb应用程序的配置类中声明jsp自定义标记

如何在JavaWeb应用程序的配置类中声明jsp自定义标记,jsp,configuration,taglib,Jsp,Configuration,Taglib,我在Java web项目中使用配置类而不是web.xml。我已经创建了标记处理程序类,并在WEB-INF目录中定义了一个TLD文件。现在,我需要在web应用程序中包含jsp自定义标记库。如果有人给我一些在我的配置类中声明TLD的示例,我将不胜感激,如下所示: @Configuration @EnableWebMvc @ComponentScan(basePackages = "com.**") @EnableAspectJAutoProxy public class AppConfig exte

我在Java web项目中使用配置类而不是web.xml。我已经创建了标记处理程序类,并在WEB-INF目录中定义了一个TLD文件。现在,我需要在web应用程序中包含jsp自定义标记库。如果有人给我一些在我的配置类中声明TLD的示例,我将不胜感激,如下所示:

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.**")
@EnableAspectJAutoProxy
public class AppConfig extends WebMvcConfigurerAdapter{
    @Autowired
    RoleToUserProfileConverter roleToUserProfileConverter;

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {

        InternalResourceViewResolver viewResolver = new   InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/views/");
        viewResolver.setSuffix(".jsp");
        registry.viewResolver(viewResolver);
    }


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("/static/");
    }

}

我最终使用java注释(TLDGen)生成了我的TLD。一个完美的例子是:

TLDGen是一个没有外部依赖项的独立库。这是生成我们自己的TLD文件的一个重要要求