1. 程式人生 > >BIM專案中一些高可用程式碼

BIM專案中一些高可用程式碼

1.頁面顯示記憶體使用情況

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JVM memory</title>
</head>
<body>
<%
double total = (Runtime.getRuntime().totalMemory()) / (1024.0 * 1024);
double max = (Runtime.getRuntime().maxMemory()) / (1024.0 * 1024);
double free = (Runtime.getRuntime().freeMemory()) / (1024.0 * 1024);
out.println("Java 虛擬機器試圖使用的最大記憶體量(當前JVM的最大可用記憶體)maxMemory(): " + max + "MB<br/>");
out.println("Java 虛擬機器中的記憶體總量(當前JVM佔用的記憶體總數)totalMemory(): " + total + "MB<br/>");
out.println("Java 虛擬機器中的空閒記憶體量(當前JVM空閒記憶體)freeMemory(): " + free + "MB<br/>");
out.println("JVM實際可用記憶體: " + (max - total + free) + "MB<br/>");
%>
</body>
</html>

2.通用action配置

		<action name="*_*_*_*" class="{1}Action" method="{2}">		
			<result name="success">pages/{3}/{4}.jsp</result>
			<result name="error">pages/{3}/{4}.jsp</result>
			<result name="toquery" type="redirect">{4}.action</result>	
			<result name="noprivilege">pages/login/noPrivilege.jsp</result>
		</action>
		<action name="*_*" class="{1}Action" method="{2}">
		</action>
		<action name="*.*.*" class="{1}Action" method="{2}">			
			<result name="success">pages/{3}.jsp</result>		
			<result name="error">pages/{3}.jsp</result>
			<result name="toindex">/pages/login/goPortal.jsp</result>	
		</action>


3.ArrayUtil

	public static Object[] unionArray(Object[] array1, Object[] array2, Object[] array3){
		List<Object> tempList = new ArrayList<Object>();
		for(int i=0; i<array1.length; i++){
			tempList.add(array1[i]);
		}
		for(int i=0; i<array2.length; i++){
			tempList.add(array2[i]);
		}
		for(int i=0; i<array3.length; i++){
			tempList.add(array3[i]);
		}
		return tempList.toArray();
	}
	public static Object[] unionArray(Object[] array1, Object[] array2){
		List<Object> tempList = new ArrayList<Object>();
		for(int i=0; i<array1.length; i++){
			tempList.add(array1[i]);
		}
		for(int i=0; i<array2.length; i++){
			tempList.add(array2[i]);
		}
		return tempList.toArray();
	}
	
	public static Object[] insertNullObject(Object[] arr){
		List<Object> objectList = new ArrayList<Object>();
		for(int i=0; i<arr.length; i++){
			objectList.add(arr[i]);
			objectList.add("");
		}
		return objectList.toArray();
	}