JYGL学习3 javascript&strut upload

本文介绍了如何使用JavaScript控制文本框样式,通过正则表达式验证文件上传格式,并利用CLOB进行文件存储的方法。此外,还涉及了如何实现点击表格行改变背景色的功能及窗口间的交互操作。

 1.文本框的样式控制
/*鼠标经过字段时聚集并有蓝色框框提示*/
function onFocusClassName (obj, NowClass)
 {
  document.getElementById(obj).className = NowClass;
 }

/*鼠标指向时聚焦,经过时是一种样式,离开时又恢复原来的样式*/
<textarea onkeyup="sizeCheck(this,200)" name="qksm" id="qksm" value="" cols="19" rows="3" wrap="VIRTUAL" tabIndex="4" onmouseover="this.focus();this.select();" onfocus="onFocusClassName('qksm', 'focus_normal')" onblur="onFocusClassName('qksm', 'blur_normal')" ></textarea>
2.上传附件,用正则表达式判断格式
 <html:form action="wwjy.do?method=add" enctype="multipart/form-data" onsubmit="return tijiao()">
<tr>
    <td>附件:</td>
      <td>
      <html:file property="zhqk" value="浏览"></html:file>
      </td>
  </tr>
 </html:form>
function tijiao(){
 var bz = document.all.zhqk.value;
if(bz!=""){
    reg=//.([^/.]+)$/;                         //?
    var e=reg.exec(bz)[1].toLowerCase();      //?
    if(e!="doc"){
    alert("上传文件格式错误,请上传word文档!");  
    return false;
    }
   }
3.更好的上传方法 CB: CLOB(字符大数据量对象);??回去再看看
  sqlserver中定义类型为:image
  数据库中存放的就是文件:<二进制数据>,还不是路径了。
原来用的是struts的方法
<html:form action="wwjy.do?method=add" enctype="multipart/form-data" onsubmit="return tijiao()">
<tr>
    <td>附件:</td>
      <td>
      <html:file property="zhqk" value="浏览"></html:file>
      </td>
  </tr>
<tr>
    <td>名称:</td>
      <td>
      <input type="text" name="title" />
      </td>
  </tr>
<html:submit value="保存"/>
 </html:form>

上传,其它的字段还是用request.getParameter();来取得

org.apache.struts.upload.FormFile file=request.getparameter("zhqk");
InputStream in = file.getInputStream();
插入附件的(图片,文件都可以)
if(in.available()>0){
in.available();}
BinaryStream


下载image类型的文件
<a href="wwjy.do?method=down&ID=<%=vo.getID()%>&filename=zhqk.doc">
    <img src="images/edit.gif" border="0" alt="转化情况.doc"/></a>
public ActionForward down....
 {
  HttpSession session = request.getSession();
  String fileName = request.getParameter("filename");
  String ID = request.getParameter("ID");
  response.setContentType("application/msdownload;charset=GB2312");
  String contentDisposition = (new StringBuilder("attachment; filename=")).append(toUtf8String(fileName)).toString();
  response.setHeader("Content-Disposition", contentDisposition);
  java.io.OutputStream out = response.getOutputStream();
  ...(部份非重要代码省略)
                String sql=select zhqk from wwjy where id="+id;
                 if(rs.next())
                  {
      byte b[] = new byte[1024];
   InputStream in = rs.getBinaryStream("zhqk");
   for (int len = 0; (len = in.read(b)) != -1;)
   {
    out.write(b, 0, len);  //下载了。。。
    out.flush();
   }
   out.close();
   in.close();
                    }
  return null;
 }

4.window.dialogArguments.window.location  (弹出窗口中的代码)
  window.close(); //关闭子窗口
//window.dialogArguments 对应父窗口 这样做是为了在子窗口中操作后,跳到action,回来时不是子窗口,而是返回父窗口
5.点击表格一行,颜色变,还可以做各种添加删除都操作
  function dj(name){
 name.bgColor="#cccfff";
 var ID=name.getid; 
 document.all.ID.value=ID;
 }
<tr onclick="dj(this)" getid="<%=vo.getID()%>">
 <input type="hidden" name="ID" value="" >

     var ID=document.all.xh.value;//取值,看哪一行被选中
 document.all.ID.value="";//清空存储值
 if(ID!=""){
 url="<%=path %>/wwjy.do?method=edit&ID="+ID; 
                 window.showModalDialog(url,arguemnts,"dialogHeight:330px;dialogWidth:320px;dialogTop:270px;dialogLeft:300px;status:no;unadorned:no;scroll:no;resizable:no;edge:sunken;");      
  }
 else{   alert("请选择您要修改的记录!")   }
 }
6.查一下
var arguemnts = new Object(); 
  arguemnts.window = window;  //这是做什么用的???上下级窗口的转来转出。。。糊里糊涂
    window.showModalDialog(....
 var arguemnts = new Object();
7.打印一个页面(样式为黑细线)
写法:
<table border="1" style="border-collapse: collapse;"  cellspacing="0" cellpadding="0">
1 建立HTML的Object标签,调用WebBrowser控件。
 <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT/>
    直接弹出打印预览了。
2 <body onload="dayan()">
<script type="text/javascript">
           function dayan(){
                  document.all.WebBrowser.ExecWB(7,1);//(7,1)是打印预览,(6,6)是直接打印,(8,1)是页面设置
                   }
      </script>
8.

ERROR TypeError: Cannot convert undefined or null to object TypeError: Cannot convert undefined or null to object at Function.assign () at /home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@dcloudio+vue-cli-plugin-uni@2.0.2-4070620250821001/node_modules/@dcloudio/vue-cli-plugin-uni/lib/chain-webpack.js:53:34 at Object.tap (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/webpack-chain@6.5.1/node_modules/webpack-chain/src/Use.js:14:20) at /home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@dcloudio+vue-cli-plugin-uni@2.0.2-4070620250821001/node_modules/@dcloudio/vue-cli-plugin-uni/lib/chain-webpack.js:53:12 at Array.forEach () at /home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@dcloudio+vue-cli-plugin-uni@2.0.2-4070620250821001/node_modules/@dcloudio/vue-cli-plugin-uni/lib/chain-webpack.js:22:17 at /home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@vue+cli-service@5.0.9_prettier@3.6.2_sass-loader@13.3.3_vue-template-compiler@2.7.16_vue@2.7.16_webpack-sources@1.4.3/node_modules/@vue/cli-service/lib/Service.js:268:40 at Array.forEach () at Service.resolveChainableWebpackConfig (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@vue+cli-service@5.0.9_prettier@3.6.2_sass-loader@13.3.3_vue-template-compiler@2.7.16_vue@2.7.16_webpack-sources@1.4.3/node_modules/@vue/cli-service/lib/Service.js:268:26) at Service.resolveWebpackConfig (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@vue+cli-service@5.0.9_prettier@3.6.2_sass-loader@13.3.3_vue-template-compiler@2.7.16_vue@2.7.16_webpack-sources@1.4.3/node_modules/@vue/cli-service/lib/Service.js:272:48) at PluginAPI.resolveWebpackConfig (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@vue+cli-service@5.0.9_prettier@3.6.2_sass-loader@13.3.3_vue-template-compiler@2.7.16_vue@2.7.16_webpack-sources@1.4.3/node_modules/@vue/cli-service/lib/PluginAPI.js:132:25) at serve (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@dcloudio+vue-cli-plugin-uni@2.0.2-4070620250821001/node_modules/@dcloudio/vue-cli-plugin-uni/commands/serve.js:51:31) at Service.run (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/@vue+cli-service@5.0.9_prettier@3.6.2_sass-loader@13.3.3_vue-template-compiler@2.7.16_vue@2.7.16_webpack-sources@1.4.3/node_modules/@vue/cli-service/lib/Service.js:262:12) at processTicksAndRejections (internal/process/task_queues.js:95:5) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! jeecg-boot-h5@0.1.0 dev:h5: `cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the jeecg-boot-h5@0.1.0 dev:h5 script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2025-10-29T03_03_43_662Z-debug.log  ELIFECYCLE  Command failed with exit code 1. 请帮我分析并解决以上问题
10-30
ERROR in ./src/main.js Module build failed: Error: Unknown keyword formatMinimum at get (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/ajv-keywords@5.1.0_ajv@8.17.1/node_modules/ajv-keywords/dist/index.js:25:15) at ajvKeywords (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/ajv-keywords@5.1.0_ajv@8.17.1/node_modules/ajv-keywords/dist/index.js:10:13) at Object. (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/schema-utils@2.7.1/node_modules/schema-utils/dist/validate.js:58:1) at Module._compile (node:internal/modules/cjs/loader:1165:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10) at Module.load (node:internal/modules/cjs/loader:1043:32) at Function.Module._load (node:internal/modules/cjs/loader:878:12) at Module.require (node:internal/modules/cjs/loader:1067:19) at require (node:internal/modules/cjs/helpers:103:18) at Object. (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/schema-utils@2.7.1/node_modules/schema-utils/dist/index.js:3:18) at Module._compile (node:internal/modules/cjs/loader:1165:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10) at Module.load (node:internal/modules/cjs/loader:1043:32) at Function.Module._load (node:internal/modules/cjs/loader:878:12) at Module.require (node:internal/modules/cjs/loader:1067:19) at require (node:internal/modules/cjs/helpers:103:18) at Object. (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/babel-loader@8.4.1_@babel+core@7.28.4_webpack@5.102.1/node_modules/babel-loader/lib/index.js:31:25) at Module._compile (node:internal/modules/cjs/loader:1165:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10) at Module.load (node:internal/modules/cjs/loader:1043:32) at Function.Module._load (node:internal/modules/cjs/loader:878:12) at Module.require (node:internal/modules/cjs/loader:1067:19) at require (node:internal/modules/cjs/helpers:103:18) at /home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/webpack@5.102.1/node_modules/webpack/lib/ProgressPlugin.js:495:9 at Hook.eval [as call] (eval at create (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/tapable@2.3.0/node_modules/tapable/lib/HookCodeFactory.js:19:10), :7:1) at Hook.CALL_DELEGATE [as _call] (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/tapable@2.3.0/node_modules/tapable/lib/Hook.js:16:14) at NormalModule._doBuild (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/webpack@5.102.1/node_modules/webpack/lib/NormalModule.js:998:24) at NormalModule.build (/home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/webpack@5.102.1/node_modules/webpack/lib/NormalModule.js:1252:15) at /home/project/wdckqx/sc-jygl-nbwz-web-yzl/node_modules/.pnpm/webpack@5.102.1/node_modules/webpack/lib/Compilation.js:1556:12 at NormalModule.needBuild (/hom 帮我分析并解决这个问题
10-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值