1.界面层与硬件的操作
对于java的JNA等操作,只能操作c++的dll文件对于C#的dll文件,需要对应封装的ocx组件,其可以使用js进行调用 1) 在使用ie进行调用ocx组件时,需要调低浏览器的安全等级。谷歌在45版本后就禁止调用ocx,必须使用旧版本才可,其调用方式与ie略有不同。参考链接 2)注册dll文件,需要将对用的dll文件放到电脑系统目录sys32下,在’运行’中进行注册–Regsvr32 A6IDCReader.dll 3)对于关闭ie浏览器的放大缩小,需要在系统中修改注册表来实现。参考链接
使用快捷键“windows+R”,出现“运行”,输入“regedit”
1.Launch
the Windows registry editor
2.Navigate
'HKEY_CURRENT_USER/SoftwareMicrosoft/Internet Explorer/Zoom' (HKEY_LOCAL_MACHINE works also).
3.Create
a DWORD
value named
'ZoomDisabled' and set it’s
value to 1.
4.Restart your kiosk application
2.对于javaweb中的编码问题
界面层 –>后端:使用ajax发送请求时,请求的头文件中不同的浏览器是不同的。谷歌浏览器中规定了当前浏览器的编码,而ie中是没有规定编码的。所以在发送请求时,如果数据中包含中文字符,最好使用$.ajax()进行发送。对于逻辑层而言:在解析数据等操作时,例如json的转换,若不规定编码格式,系统会默认遵循JVM的编码,而JVM的编码又根据电脑系统所设置的时区进行自动识别。在eclipse中可进行设置jvm的编码,而单独在Tomcat的运行环境中,是需要特别注意编码格式。
OutputStream
out = conn
.getOutputStream()
out.write((obj
.toString())
.getBytes(
"UTF-8"))
对于持久层而言:解析时的编码如上所述,但单单对于持久层而言,可以在设置浏览器地址时设置编码格式。
jdbc.url=
jdbc:mysql:/
//activitiDemo?createDatabaseIfNotExist=
true&useUnicode=
true&characterEncoding=utf8
3.对于fastJson的方式解析json字符串
这种方式的解析最大优势在于json与javabean的相互转化。 其需要注意的是,对于返回的json字符串进行解析时,所需的解析使用的相对应的javabean要单独class的存在,解析数据的每一层都是如此。
public static
List<Results
> getRoomDataByPhone(Results resultx) {
List<Results
> results
= new ArrayList
<Results
>();
try {
resultSession
= initLogin();
if (
"fail".equals(resultSession)) {
return null;
}
List<Data> list = new ArrayList
<Data>();
Data data = new PmsClientUtil()
.new Data(resultx
.getName(),resultx
.getIdent(),resultx
.getAccnt(),resultx
.getRsvno(),
resultx
.getRoomno(),resultx
.getRate(),resultx
.getRatecode(),resultx
.getRmtype(),
resultx
.getArr(), resultx
.getDep());
data.setHotelid(paramsId);
list.add(
data);
Map<String, Object
> obj
= new HashMap
<String, Object
>();
Date now
= new Date();
obj
.put(
"appkey", appkey);
obj
.put(
"method",
"xmsopen.reservation.xopqueryreservation");
obj
.put(
"ver",
"1.0.0");
obj
.put(
"hotelid", hotelId);
obj
.put(
"loc",
"zh_CN");
obj
.put(
"ts", now
.getTime());
obj
.put(
"session", resultSession);
obj
.put(
"params",
list);
JSONObject jsonString
= new JSONObject(obj);
LogUtil
.sysoLog(
"PMS getRoomData SendJson",jsonString);
String result
= postPmsData(jsonString);
LogUtil
.sysoLog(
"PMS getRoomData ResultJson",result);
ResultData ss
= JSON
.parseObject(result, ResultData
.class);
results
= ss
.getResults();
return results;
} catch (Exception e) {
return null;
}
}
4.对于发送json格式请求工具
public static String
postPmsData(JSONObject obj) {
try {
URL url =
new URL(URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(
true);
conn.setDoInput(
true);
conn.setUseCaches(
false);
conn.setRequestMethod(
"POST");
conn.setRequestProperty(
"Connection",
"Keep-Alive");
conn.setRequestProperty(
"Content-type",
"application/json;charset=UTF-8");
byte[] data = (obj.toString()).getBytes();
conn.setRequestProperty(
"Content-Length",
String.valueOf(data.length));
conn.setRequestProperty(
"contentType",
"application/json");
conn.connect();
OutputStream
out = conn.getOutputStream();
out.write((obj.toString()).getBytes(
"UTF-8"));
out.flush();
out.close();
if (conn.getResponseCode() ==
200) {
BufferedReader br =
new BufferedReader(
new InputStreamReader(
conn.getInputStream(),
"UTF-8"));
String line =
"";
String result =
"";
while (
null != (line = br.readLine())) {
result += line;
}
return result;
}
else {
System.
out.println(
"no++");
return null;
}
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
5.对于解析asciicode
private static String
ascii2native ( String asciicode )
{
String[] asciis = asciicode.split (
"\\\\u");
String nativeValue = asciis[
0];
try
{
for (
int i =
1; i < asciis.length; i++ )
{
String code = asciis[i];
nativeValue += (
char) Integer.parseInt (code.substring (
0,
4),
16);
if (code.length () >
4)
{
nativeValue += code.substring (
4, code.length ());
}
}
}
catch (NumberFormatException e)
{
return asciicode;
}
return nativeValue;
}