开发片断代码

1、JShtml

    1.划分私有空间,对属性和操做作访问控制spring

    var example=(function(){
          var a=123;
          var add=function(v1,v2){
                return v1+v2;
          }
          var devide=function(v1,v2){
                return v1/v2;
          }json

        //此处不返回的属性或操做,外部是不能访问的。
          return{
            add:add,  
          }
    })();
    //调用
    var test=example()
    test.add(1,2);
    //若是对test新增操做,既是对新增开放,对修改关闭
    var example=(function(exa){
      exa.mod=function(v1,v2){
        return v1%v2;
      }
      return exa;
    })(window.example||{});//此处指明内部模块依赖,或者是申明内部模块依赖了那些东西mvc

 

2、JAVAapp

1.解决FastJson序列化时检查对象循环引用,致使解析出"$ref"这样的东西ide

    环境:SpringMVC,code

    修改地方:FastJson视图解析器处的配置文件,修改以下:orm

<!-- fastjson视图解析器 -->
	<mvc:annotation-driven>
		<mvc:message-converters register-defaults="true">
			<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
			<bean id="fastJsonHttpMessageConverter"
				class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
				<property name="supportedMediaTypes">
					<list>
						<!-- 这里顺序不能反,必定先写text/html,否则ie下出现下载提示 -->
						<value>text/html;charset=UTF-8</value>
						<value>application/json;charset=UTF-8</value>
					</list>
				</property>
				<property name="features">
					<list>
						<value>WriteMapNullValue</value>
						<value>QuoteFieldNames</value>
						<value>WriteDateUseDateFormat</value>
						<array value-type="com.alibaba.fastjson.serializer.SerializerFeature">  
			           		<value>DisableCircularReferenceDetect</value>  
			       		</array> 
					</list>
					
				</property>
			</bean>
		</mvc:message-converters>
	</mvc:annotation-driven>
	<!-- 配置不检查对象循环引用"-->
 	<bean id="DisableCircularReferenceDetect" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">  
      <property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.DisableCircularReferenceDetect"></property>  
   </bean>
相关文章
相关标签/搜索