uixml+H5 demo

config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config scope="client" clientversion="4" devicetype="all" theme="skin-default"> 
  <appid>dwtemplate</appid>  
  <appname>dwtemplate</appname>  
  <description></description>  
  <version>1.0.0</version>  
  <date>2016-02-03</date>  
  <homepage src="res:page/template.uixml"/>  
  <faultconfig src=""/>  
  <access network="true" gps="true" camera="true" certificate="true" land="false" orientation="port"/>  
  <vendor email="" url=""/>  
  <icon main="res:image/main.png" logo="res:image/logo.png"/> 
</config>

 

template.uixml

<!-- ExMobi UIXML(XHTML)文件 -->
<html>
	<head>
		<title show="false"></title>	
		<meta content="charset=utf-8"/>
		<script>
		<![CDATA[
			
		]]>
		</script>
	</head>
	<body>
		<webview url="res:page/template.html"></webview>		
	</body>
</html>

 

template.html

<!-- HTML5文件 -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>ceshi</title>
		<script type="text/javascript" src="../script/jquery-3.1.0.min.js"></script>
		<script>
			$(document).ready(function(){
				$("#load").click(function(){
						$.get("http://localhost:8001/process/service/dwtemplate/template", function(data, status) {
							alert(data.dw);
						});
				});
			})
		</script>
	</head>
	<body>
		<button id="load">加載</button>
	</body>
</html>

 

mapp.xml

<?xml version="1.0" encoding="UTF-8" ?>
<maxml version="2.0" xmlns="http://www.nj.fiberhome.com.cn/map"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.nj.fiberhome.com.cn/map maxml-2.0.xsd">
	<config>
		<htmlformat wellformat="true" />
		<filepreviewconfig wordtohtml="false" />
	</config>

	<services>
		<http-filter name="template" file="template.jsp">
			<url-pattern>/template</url-pattern>
		</http-filter>
		<http-service-ext extfile="testapi.ac" />
	</services>
</maxml>

 

 

template.jsp

<%-- ExMobi JSP文件,註釋和取消快捷鍵統一爲Ctrl+/ 多行註釋爲Ctrl+Shift+/ --%>
<%@ page language="java" import="java.util.*"
 contentType="application/uixml+xml; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/client/adapt.jsp"%>
<%@ include file="/client/adapt_extend.jsp"%>
<aa:http id="template" url='<%="http://localhost:8001/process/service/dwtemplate/data/template.json"%>' method="get"/>
<%
	String data = aa.regex(".*", "template");
	System.out.print(data);
	response.setCharacterEncoding("UTF-8");
	response.setContentType("application/json; charset=utf-8");
	response.addHeader("Access-Control-Allow-Origin", "*");
	response.getWriter().write(data);
%>

template.json

{
	"dw":"測試json"
}

 

testapi.ac

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<maxml-api xsi:schemaLocation="http://www.nj.fiberhome.com.cn/map ../../../maxml-api-2.0.xsd" xmlns="http://www.nj.fiberhome.com.cn/map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <http-service id="testapi" isrest="true" name="測試模塊">
        <forward method="get" name="測試" path="template.jsp" pattern="/template"/>
    </http-service>
</maxml-api>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章