Here

如何直接初始化HashMap(以字面方式)? [重复]

帅比萌擦擦* 提交于 2020-08-16 11:24:01
问题: This question already has an answer here: 这个问题已经在这里有了答案: How can I initialise a static Map? 如何初始化静态地图? 42 answers 42个答案 Is there some way of initializing a Java HashMap like this?: 有没有办法像这样初始化Java HashMap? Map<String,String> test = new HashMap<String, String>{"test":"test","test":"test"}; What would be the correct syntax? 正确的语法是什么? I have not found anything regarding this. 我还没有发现任何有关此的信息。 Is this possible? 这可能吗? I am looking for the shortest/fastest way to put some "final/static" values in a map that never change and are known in advance when creating the Map. 我正在寻找在地图中放置一些“最终/静态”值的最短/最快方法

类型检查:typeof,GetType还是?

耗尽温柔 提交于 2020-08-16 11:00:52
问题: I've seen many people use the following code: 我见过很多人使用以下代码: Type t = typeof(obj1); if (t == typeof(int)) // Some code here But I know you could also do this: 但我知道您也可以这样做: if (obj1.GetType() == typeof(int)) // Some code here Or this: 或这个: if (obj1 is int) // Some code here Personally, I feel the last one is the cleanest, but is there something I'm missing? 就个人而言,我觉得最后一个是最干净的,但是我缺少什么吗? Which one is the best to use, or is it personal preference? 哪一种是最佳使用方式,还是个人喜好? 解决方案: 参考一: https://stackoom.com/question/47jK/类型检查-typeof-GetType还是 参考二: https://oldbug.net/q/47jK/Type-Checking-typeof-GetType-or

HTML为什么认为“ chucknorris”是一种颜色?

独自空忆成欢 提交于 2020-08-16 09:48:47
问题: How come certain random strings produce colors when entered as background colors in HTML? 在HTML中作为背景色输入时,某些随机字符串如何产生颜色? For example: 例如: <body bgcolor="chucknorris"> test </body> ...produces a document with a red background across all browsers and platforms. ...在所有浏览器和平台上产生 背景 为 红色 的文档。 Interestingly, while chucknorri produces a red background as well, chucknorr produces a yellow background. 有趣的是,虽然 chucknorri 产生红色背景,但 chucknorr 产生黄色背景。 What's going on here? 这里发生了什么? 解决方案: 参考一: https://stackoom.com/question/Yu7z/HTML为什么认为-chucknorris-是一种颜色 参考二: https://oldbug.net/q/Yu7z/Why-does-HTML-think

图像处理:“可口可乐”识别的算法改进

社会主义新天地 提交于 2020-08-16 08:20:36
问题: One of the most interesting projects I've worked on in the past couple of years was a project about image processing . 我过去几年中最有趣的项目之一是关于 图像处理 的项目。 The goal was to develop a system to be able to recognize Coca-Cola 'cans' (note that I'm stressing the word 'cans', you'll see why in a minute). 目的是开发一个能够识别可口可乐 “罐头”的系统 (请注意,我强调的是“罐头”一词,稍后您会看到原因)。 You can see a sample below, with the can recognized in the green rectangle with scale and rotation. 您可以在下面看到一个示例,该示例在带有刻度和旋转的 绿色矩形中 可以识别。 Some constraints on the project: 对项目的一些限制: The background could be very noisy. 背景可能非常嘈杂。 The can could have any

Windows7右键菜单栏添加打开cmd项

筅森魡賤 提交于 2020-08-16 06:07:25
背景简介 众所周知,在Linux桌面操作系统中的工作目录窗口中,单击鼠标右键,弹出的菜单栏通常有一项“打开终端”,然后移动鼠标点击该项,就可以打开Shell窗口,在当前工作目录进行命令行操作。 但是,在Windows7操作系统默认情况下,是没有这便捷功能。若想打开Windows7的命令行cmd,就先按住键盘的 Win + R ,然后输入 cmd ,才能打开命令行窗口,必要还要切换工作目录,挺麻烦的。 幸运的是,只需通过几步简单操作,便可在Window7上拥有类似Linux的,单击鼠标右键后的弹出菜单有“打开cmd”的功能选项。 操作步骤 键盘按住 Win + R ,然后输入 regedit ,打开注册表编辑器。 在注册表编辑器左边找出HKEY_CLASSES_ROOT\Directory\Background\shell ,然后右键点击它,新建一项叫 Cmd Here 然后在 Cmd Here 项,新建一 字符串值 ,数值名称为 Icon ,数值数据为 C:\Windows\System32\cmd.exe 。该功能就用来显示cmd的小图标。 然后继续在 Cmd Here 项,新建一 项 ,名为 command ,然后在右侧双击默认项,把它的数值数据修改为 cmd 。 结语 通过上述的几步操作,便可在Window7上,单击鼠标右键后的弹出菜单有“打开cmd”的功能选项。 参考资料

ssm框架实现图片上传显示并保存地址到数据库

僤鯓⒐⒋嵵緔 提交于 2020-08-16 03:44:28
本案例是通过springmvc+spring+mybatis框架以商品上传为例,实现的图片上传功能,并把图片的地址保存到数据库并在前台显示上传的图片。 本项目是使用maven搭建的项目,首先看下项目结构 相关配置自行搜索,下边直接实现上传功能 1.创建数据库 DROP TABLE IF EXISTS `product`; CREATE TABLE `product` ( `pid` int(11) NOT NULL AUTO_INCREMENT, `pimage` varchar(255) DEFAULT NULL, PRIMARY KEY (`pid`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of product -- ---------------------------- INSERT INTO `product` VALUES ('2', '6c648d82-dc29-4b92-855e-491741e092a21.jpg'); INSERT INTO `product` VALUES ('3', '80f26905-7342-492c-be6e-c3f0ad81c2aa1.jpg'); INSERT INTO

Git Push错误:没有足够的权限向存储库数据库添加对象

ⅰ亾dé卋堺 提交于 2020-08-16 01:45:58
问题: When I try to push to a shared git remote, I get the following error: insufficient permission for adding an object to repository database 当我尝试推送到共享git远程时,出现以下错误: insufficient permission for adding an object to repository database Then I read about a fix here: Fix This worked for the next push, since all of the files were of the correct group, but the next time someone pushed up a change it made a new item in the objects folder that had their default group as the group. 然后,我在此处了解到一个修复程序: 修复 此操作适用于下一次推送,因为所有文件都属于正确的组,但是下次有人推送更改时,它将在具有默认组的对象文件夹中创建一个新项目作为组。 The only thing I can think of is to

使用Spring Shell 快速开发自己的命令交互窗口

强颜欢笑 提交于 2020-08-15 21:52:43
Spring Shell 有时候,为了方便开发和测试服务器,并不需要一个漂亮的用户界面,使用一个简单的命令窗口即可。如下所示: 这里介绍一个快速,方便,易用,简单的交互式命令窗口开发组件-Spring Shell 没错,又是spring 生态中的。 源码地址 https://gitee.com/wgslucky/spring-shell-demo 创建项目 本项目是使用Eclipse作为开发的IDE,同样,直接导入到Idea之中也可以使用。使用的JDK需要是1.8或更高的版本,我测试过在JDK11上也可以使用。 在eclipse中创建maven项目:spring-shell-demo,然后在pom.xml中添加如下依赖: <parent> <!-- 添加spring boot 父pom依赖,这个不能少,spring shell官方的文档中没有写 --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.6.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId>

[原创][开源] SunnyUI.Net 开发日志:ListBox 增加跟随鼠标滑过高亮

梦想与她 提交于 2020-08-15 21:48:50
SunnyUI.Net, 基于 C# .Net WinForm 开源控件库、工具类库、扩展类库、多页面开发框架 Blog: https://www.cnblogs.com/yhuse Gitee: https://gitee.com/yhuse/SunnyUI GitHub: https://github.com/yhuse/SunnyUI SunnyUI.Net 系列文章目录 欢迎交流,QQ群:56829229 (SunnyUI技术交流群) SunnyUI.Net 开发日志:ListBox 增加跟随鼠标滑过高亮 QQ群里,寸木说,ListBox鼠标移动时,当前行需要焦点,我想了想,不难实现啊 不就是在鼠标移动时重绘Item嘛,何况选中的Item已经改了颜色了。 见UIListBox代码: protected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); BeforeDrawItem?.Invoke(this, Items, e); if (Items.Count == 0) { return; } e.DrawBackground(); if (e.Index < 0 || e.Index >= Items.Count) { return; } StringFormat

诺禾:在jsp里面如何不写java代码展示数据(EL表达式的使用)

这一生的挚爱 提交于 2020-08-15 21:48:06
EL表达式可以简化jsp中写的java代码 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) EL如果没有获取到值会显示空字符串而不是显示null 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) 在jsp里面如何不写java代码展示数据(EL表达式的使用) <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>el的隐式对象</title> </head> <body> ${pageContext.request}<br> <h4>在jsp页面动态获取虚拟目录</h4> $