JAVA WEB START 在项目中遇到的问题及解决

来源:互联网 发布:手机高清录屏软件 编辑:程序博客网 时间:2024/06/06 08:26
 
 
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日星期二
 
原创粉丝点击