首页
学习
活动
专区
工具
TVP
发布

java大数据

专栏作者
627
文章
445625
阅读量
29
订阅数
javascript当中静态方法和prototype用法
6)静态方法和prototype(难) 例 3.6.1 <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> </head> <script> /*note that 马克-to-win: static variable's value has nothing to do with instance's variable's value.instance 名称 can not 直接access static member like in java. This is different from Java,比如下面例子中,Student.number=2,但是d1.number就为undefined.This is different from Java,但在实例方法中(比如d1.info)可以访问Student.number。这是和java中一样的。或者说function外或任何地方都可以访问Student.number。反过来,d1.age也可以在静态方法中访问,就像在function外一样,任何地方都能访问d1.age。String.prototype.abcd,这是给所有的实例加属性而不是静态属性。*/ function Student(number, agev) { this.age = agev; /*static variable's value can not be accessed by instance */ Student.number = number; /*lb is local variable, but not a member variable because it is not modified by this. from outside it can not be accessed. refer to noblockScope.html */ var lb = 0; } var d1 = new Student(1, 3); document.writeln("this的age属性为means window.age" + this.age + "<br>"); document.writeln("d1的age属性为" + d1.age + "<br>"); document.writeln("d1的number属性为" + d1.number + "<br>"); document.writeln("通过Student访问静态number属性为" + Student.number + "<br>"); document.writeln("d1的lb属性为" + d1.lb + "<br><hr>"); d1.qixy = "abc";/*以随意为实例加属性或方法*/ document.writeln("可以随意为实例加属性或方法see following,d1的qixy属性为" + d1.qixy + "<br><hr>"); document.writeln("是否有静态变量qixy" + Student.qixy + "<br><hr>"); d1.info = function()/*此方法仅为d1对象所用*/ { document.writeln("对象的qixy属性:" + this.qixy); document.writeln("对象的age属性:" + this.age); /*下列话是合法的, 因为不是this.number, 而是Student.number*/ document.writeln("static method is " + Student.number); }; Student.prototype.infop = function()/*此方法可以为所有Student对象所用*/ { document.writeln("对象的qixy属性p:" + this.qixy); document.writeln("对象的age属性p:" + this.age);
马克java社区
2019-10-09
4290
SpringBoot中如何上传Upload
上传: 根据第3部分的helloworld例子,用那个项目做底子。pom.xml都不用改变。参考项目bootUpload1. static/index.html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> index1 <form method="POST" action="/upload" enctype="multipart/form-data"> <input type="file" name="file" /><br/><br/> <input type="submit" value="Submit" /> </form> </body> </html> package com.SpringbootMaven; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import javax.servlet.http.HttpServletResponse; @Controller public class UploadController { private static String UPLOADED_FOLDER = "e://temp//"; @RequestMapping("/upload") public void singleFileUpload(@RequestParam("file") MultipartFile file,HttpServletResponse res) throws IOException { try { byte[] bytes = file.getBytes(); Path path = Paths.get(UPLOADED_FOLDER + file.getOriginalFilename()); Files.write(path, bytes); System.out.println("马克-to-win@马克java社区 successfully"); } catch (IOException e) { e.printStackTrace(); } res.sendRedirect("index.html"); } }
马克java社区
2019-07-27
4820
没有更多了
社区活动
RAG七天入门训练营
鹅厂大牛手把手带你上手实战
Python精品学习库
代码在线跑,知识轻松学
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档