-3
我正在嘗試開發手機gap.It應用程序監視服務器作業。目前服務器不可用,所以我將我的系統作爲服務器。我把項目文件放在我的服務器安裝在同一個目錄下。我正嘗試在主要活動中訪問我的文件。但它在我的模擬器上顯示錯誤。錯誤標題是協議不支持。我在下面共享主要活動文件和html文件。請看這些文件。 主要活動文件:不支持協議(Android)
package com.example.productionmonitor;
import org.apache.cordova.DroidGap;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends DroidGap{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("Here");
super.setIntegerProperty("loadUrlTimeoutValue",120000);
super.loadUrl("file////C:/Program Files/Elixir Technologies/Tango/tomcat/webapps/productionmanagerserver/Monitor app/productionMonitor.htm");
//super.loadUrl("file:///android_asset/www/productionMonitor.htm");
//super.loadUrl("C:///|\Program Files\/Elixir Technologies\/Tango\tomcat\webapps\productionmanagerserver\Monitor app\productionMonitor.htm");
//super.loadUrl("http:///localhost:8080/productionmanagerserver/productionMonitor.htm");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
這是HTML文件我保存在位置(C:\ Program Files文件\藥劑技術\探戈\ tomcat的\的webapps \ productionmanagerserver \監控應用\ login.html的)和我想訪問這個文件。
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Login</title>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Varela+Round">
<link rel="stylesheet" href="./files/login.css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>
var strFile ;
function userLogin()
{
window.location.href = "productionMonitor.htm";
}
function init()
{
var xmlhttp = null ;
try {
xmlhttp = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
xmlhttp = new ActiveXObject("MsXML2.XMLHTTP");
} catch (othermicrosoft) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
xmlhttp = null;
}
}
}
if (xmlhttp == null)
alert("Error creating request object!");
if ("withCredentials" in xmlhttp) {
// Check if the XMLHttpRequest object has a "withCredentials" property.
// "withCredentials" only exists on XMLHTTPRequest2 objects.
//xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
// Otherwise, check if XDomainRequest.
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
xmlhttp = new XDomainRequest();
}
return xmlhttp ;
}
function CallWebservice()
{
var req = init() ;
var url ="http://localhost:8080/identityserver/domains/allData";
req.open('GET',url,true);
req.send(null);
req.onreadystatechange = function() {
if (req.readyState != 4) return; // Not there yet
if (req.status != 200) {
// Handle request failure here...
alert("Call failed");
return;
}
// Request successful, read the response
strFile = req.responseText ;
parseDomainList(strFile);
}
}
function parseDomainList(dlist)
{
var xmlDoc = new DOMParser().parseFromString(strFile,'text/xml');
var domain = xmlDoc.getElementsByTagName("domain");
for (i=0;i<domain.length;i++)
{
var dname =domain[i].getElementsByTagName("domain_name");
var domainid = document.getElementById("domain") ;
var option=document.createElement("option");
domainid.appendChild(option);
}
alert(strFile) ;
userLogin() ;
}
</script>
</head>
<body>
<div id="login">
<h2><span class="fontawesome-lock"></span>Sign In</h2>
<form action="javascript:void(0);" method="POST">
<fieldset>
<p><label for="email">User Name</label></p>
<p><input type="email" id="email" value="admin" onBlur="if(this.value=='')this.value='admin'" onFocus="if(admin')this.value=''"></p>
<p><label for="password">Password</label></p>
<p><input type="password" id="password" value="admin" onBlur="if(this.value=='')this.value='admin'" onFocus="if(this.value=='admin')this.value=''"></p>
<p><label for="domain">Domain List</label></p>
<p><select type="domain" id="domain"> </select> </p>
<p><input type="submit" value="Sign In" onclick="CallWebservice()"></p>
</fieldset>
</form>
</div> <!-- end login -->
</body>
</html>