How to setup jsp-config at JavaConfig

前端 未结 2 1655
甜味超标
甜味超标 2021-01-14 02:22

in web.xml


    
         
        JSPConfiguration<         


        
相关标签:
2条回答
  • 2021-01-14 02:40

    this code should work:

        JspConfigDescriptor j = new JspConfigDescriptor()
        {
    
            @Override
            public Collection<TaglibDescriptor> getTaglibs()
            {
                // TODO Auto-generated method stub
                return null;
            }
    
            @Override
            public Collection<JspPropertyGroupDescriptor> getJspPropertyGroups()
            {
                Collection<JspPropertyGroupDescriptor> c = new ArrayList<JspPropertyGroupDescriptor>();
                JspPropertyGroupDescriptorImpl pgDescriptor = new JspPropertyGroupDescriptorImpl();
                pgDescriptor.setIsXml(Boolean.TRUE.toString());
                pgDescriptor.getUrlPattern().add("/js/generated/*");
                pgDescriptor.setElIgnored(Boolean.FALSE.toString());
                pgDescriptor.setPageEncoding("UTF-8");
                c.add(pgDescriptor);
                return null;
            }
        };
        servletContext.setJspConfigDescriptor(j);
    

    But last statement will be available since Tomcat 8

    0 讨论(0)
  • 2021-01-14 02:51

    You have access to it with

    servletContext.getJspConfigDescriptor().getJspPropertyGroups();
    

    returning a Collection<JspPropertyGroupDescriptor> which has an add(JspPropertyGroupDescriptor) method. JspPropertyGroupDescriptor is an interface which you have to implement. You're probably better off having a partial web.xml and partial java configuration.

    Sotirios Delimanolis Apr 24 at 16:07

    0 讨论(0)
提交回复
热议问题