Several methods of system configuration

Several methods of system configuration

 

Java annotations utilize properties file methods

 

@Value("#{prop['server.cn']}")

private String cnWebUrl;

@RequestMapping(value = "/addConObj")

public String addConObj(Model model) {

 

String language = CASUtil.getCustomer().getLanguage();

 

if ("CN".equals(language)) {

return "redirect:" +cnWebUrl + "/offer/addConObj";

}

}

 

db.properties

server.cn=http://10.0.1.222:8080/web

server.en=http://10.0.1.214:8080/web

 

//Configuration method of configuration file by annotation in Java

 

<bean id="prop" class="org.springframework.beans.factory.config.PropertiesFactoryBean" p:location="classpath:db.properties"/>

 

 

//The configuration file directly uses the configuration method of configuration

 

<context:property-placeholder location="classpath:db.properties" />

 

 

 

 

package com.esteel.common;

/**

 * 

 * <static description>

 * @author point steel

 * @data June 5, 2016

 */

public class StaticVariables

{

  /**

     * website url

     */

    public static String CN_WEB_URL = "http://localhost:8081/web"; // Chinese test environment

    public static String EN_WEB_URL = "http://localhost:8083/web"; // English test environment

    /**

     * The key corresponding to userId is stored in the session

     */

     }

 

 

<%

String topPath = request.getContextPath();

request.setAttribute("TopPath",topPath);

 

String cnSiteUrl = com.esteel.common.StaticVariables.CN_WEB_URL;

request.setAttribute("cnSiteUrl",cnSiteUrl);

String enSiteUrl = com.esteel.common.StaticVariables.EN_WEB_URL;

request.setAttribute("enSiteUrl",enSiteUrl);

 

//English address

String enUrl = "http://10.0.1.214:8080";

request.setAttribute("enUrl", enUrl);

 

//Chinese address

String cnUrl = "http://10.0.1.222:8080";

request.setAttribute("cnUrl", cnUrl);

%>

 

 

 

 

<script >

 

var cnSiteUrl = "${cnSiteUrl}";

var enSiteUrl = "${enSiteUrl}";

 

</script>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326311622&siteId=291194637