Spring mvc+freeMarker 使用jsp自定义标签

web.xml:




    xxxx
    x

    
    
        org.springframework.web.util.IntrospectorCleanupListener
    
    
        org.springframework.web.context.request.RequestContextListener
    

    
    
        contextConfigLocation
        
            classpath*:config/spring/local/emidas-wallet-*.xml,
            classpath*:config/spring/local/appcontext-core.xml
        
    
    
        log4jConfigLocation
        classpath:log/log4j.properties
    
    
        log4jRefreshInterval
        60000
    
    
        org.springframework.web.context.ContextLoaderListener
    
    
        org.springframework.web.util.Log4jConfigListener
    
    

    
    
        spring
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:config/spring/local/appcontext-servlet.xml
        
        1
    
    
        spring
        /wallet/*
    
    

    
    
        characterEncodingFilter
        org.springframework.web.filter.CharacterEncodingFilter
        
            encoding
            UTF-8
        
        
            forceEncoding
            true
        
    

    
        characterEncodingFilter
        /*
    





spring-servlet.xml




    
        
            
            
                
                    
                        text/html
                        application/json
                        application/javascript
                        text/plain
                    
                
                
            
            
                
            
        
    

    
    

    
        
        
    

    
    
    
    
    
    

    
        
        
        
        
        
            
                
                
                
            
        
    
    
    
        
        
        
            
                
            
        

        
            
                
                auto_detect
                
                UTF-8
                UTF-8
                zh_CN
                yyyy-MM-dd
                HH:mm:ss
                /spring.ftl as spring
                yyyy-MM-dd HH:mm:ss
                #
                
                true
                
                html_debug
                
            
        
    

    
    
    
        
        
            
                
                    
                    
                    
                    
                    
                    
                
                
                    
                    
                    
                    
                
            
        
        
            
                
                    
                    
                    
                
                
            
        
    




freemarker.properties:

number_format=#
classic_compatible=true

####add by danson.liu####
default_encoding=UTF-8

template_update_delay=0
#########################
template_exception_handler=rethrow


tag.java:
package com.xxxx.web.tag;

import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Tag extends BodyTagSupport {
    private static final long serialVersionUID = 1875715349277889045L;
    
    private String href;

    @Override
    public int doStartTag() throws JspException {
        pageContext.getOut().write("test"+href);
        return SKIP_BODY;
    }

   public void setHref(String href) {
        this.href = href;
    }

}

test.tld:



	"Tags"
	1.0
	pro
	/Test

	
		urlScheme
		com.xxxx.Tag
		empty
		
			href
			true
			false
		
        
            xxxxx
            true
            false
        
	


ftl:

<#assign testMob=JspTaglibs["/WEB-INF/tld/test.tld"]>



    

    
    
    
    
    

    未登录


"
   class="all">查看全部
    家分店
       

您还没有登录哦




你可能感兴趣的:(SpringMvc-,Jsp-Jstl及Tag标签)