1 JRE
运行环境自动安装问题;
在启动页面加入如下脚本:
<!--检查有没有安装JRE -->
<div style="display:none">
<object id="getMACAddress" classid="clsid:8AD9C840-044E-11D1-B3E9-
00805F499D93"
codebase="<%=context%>/jnlp/j2re-1_4_2_12-windows-i586-p.exe"
width="0" height="0">
<param name="code" value="">
<param name="archive" value="">
<!-- 在 Netscape browser 使用 -->
<comment>
<embed type="application/x-java-applet;jpi-version=1.4.2"
code="ModelMove" archive="ModelMove20.jar" width="0" height="0"
scriptable="false"
pluginspage="http://java.sun.com/j2se/1.4.2/download.html">
<noembed>
请先安装 JDK 1.4 以上的版本,若有问题请洽贵公司的客服人员,谢谢!
</noembed>
</embed>
</comment>
</object>
</div>
2 JRE
版本问题,出现打开旧的安装包问题;
在JNLP文件中,把第二行中的href 属性去掉;
正确: <jnlp spec="1.0+" codebase="webPath">
错误: <jnlp spec="1.0+" codebase="webPath" href="...">
关键:同时在action类中,通过如下流的方式直接访问 JNLP 文件;
例子如下:
String webpath =cfg.getRequest().getScheme()+
"://" +cfg.getRequest().getHeader("host")+
cfg.getRequest().getContextPath();
String realPath=getServlet().getServletContext().getRealPath
("/jnlp/accountant/actsubswtTemp.jnlp");
try {
String content = FileUtils.readFileToString(new File
(realPath), "utf-8");
content = content.replaceAll("webPath", webpath);
content = content.replaceAll("asid", asid);
content = content.replaceAll("sys", sys);
content = content.replaceAll("year", year);
cfg.getResponse().setContentType("application/x-java
-jnlp-file");
ServletOutputStream out = cfg.getResponse
().getOutputStream();
out.write( content.getBytes() );
} catch (IOException e) {
e.printStackTrace();
}
2007年1月23日星期二