For static method calls, static variables are assigned values. Spring provides a class:
Org.springframework.beans.factory.config.MethodInvokingFactoryBean
How to use the method:
Configuring in the Spring configuration file:
<bean class= "Org.springframework.beans.factory.config.MethodInvokingFactoryBean" >
<property name= " Staticmethod "value=" Com.sojson.core.domain.DomainDistribution.setDomainInfo "/>
<property name=" Arguments ">
<array>
<value>{" Convert ":" Word2spell,cn2spark,pingindic,low2up,fullhalf "} </value>
<value>{"color": "Cj,img,online,page,select,use,web"}</value>
</array>
</property>
</bean>
Name= "Staticmethod": fixed wording, as the name suggests is static method. Value= "Com.sojson.core.domain.DomainDistribution.setDomainInfo": The corresponding static method, Com.sojson.core.domain.DomainDistribution is the full path of the class, and Setdomaininfo is the static method name. Name= "Arguments": parameters, and my array is because I'm going to inject an array, which is actually a JSON array.
corresponding Java
Package com.sojson.core.domain;
Import Java.util.LinkedHashMap;
Import Java.util.Map;
Import Java.util.Set;
public class Domaindistribution {
static String x;
Static statement block
static{
x = "Test static statement block." ";
}
public static map<string,set<string>> Domainmap = new linkedhashmap<string,set<string>> ();
/**
* Static Call method Test
* @param domaininfo
/public static void Setdomaininfo (string[) domaininfo) { For
(String json:domaininfo) {
System.out.println (JSON);
}
}
}