利用js实现 禁用浏览器后退
也是查找了好多资料才找到的,这种方式,可以消除 后退的所有动作。包括 键盘、鼠标手势等产生的后退动作。
1 2 3 4 5 6 7 |
<script language="javascript"> //防止页面后退 history.pushState(null, null, document.URL); window.addEventListener('popstate', function () { history.pushState(null, null, document.URL); }); </script> |
现在,我们项目中就使用了第三种方式。在常用浏览器中,都可以禁用了后退。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//禁用浏览器返回 function fobidden_back() { //防止页面后退 history.pushState(null, null, document.URL); window.addEventListener('popstate', back_common) } //启用浏览器返回 function enable_back() { history.go(-1); window.removeEventListener('popstate', back_common) } function back_common() { history.pushState(null, null, document.URL); } |
mb里可以直接配置项禁用回退 wkeSetDebugConfig(webview, "backKeydownEnable", "0") from:利用js实现 禁用浏览器后退 (jvbaopeng.com)
View DetailsIIS 80跳转443
我的站点在443和80端口下都有部署,这样访问站点使用http和https时都可以访问到站点,但是使用http访问的站点一直会有不安全提示,这个体验很不好,就需要我们做一点工作让它自动跳转到有证书的https站点下面。 本文以站点https://www.huibenit.com为例说明怎么设置,服务器操作系统:windows2012 R2, IIS8.5 首先要做的准备是下载微软IIS下的一个Url重写模块 url-rewrite;下载地址:http://www.iis.net/downloads/microsoft/url-rewrite,目前的版本是2.1支持IIS7和IIS8。下载好后一路默认下一步安装完。 下面就开始介绍如何配置: (1)在运行里输入inetmgr打开IIS站点管理窗口,然后选择你需要设置的站点,找到Url 重写(Url rewrite)如下图所示: (2)双击“Url 重写”模块进入设置窗口,然后在右上角找到添加规则按钮,点击后如下图,再选择“空白规则”。 (3)规则设置如下: 名称:HTTPS跳转 条件:{HTTPS} 模式:off 操作类型选择:重定向 重定向URL:https://{HTTP_HOST}/{R:1} (4)最后填写完成后请点击右上角的应用(此步最重要)。 其实上面的设置过程只是一个图形操作窗口,最后填写的内容会保存在Web.Config中。我们也是可以通过修改web.config来实现上面的填写过程。 我把完整的Web.config粘贴出来如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit https://go.microsoft.com/fwlink/?LinkId=301880 --> <configuration> <appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Enabled" value="false" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <compilation targetFramework="4.6.1" /> <httpRuntime targetFramework="4.6.1" /> <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> </httpModules> </system.web> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly> </assemblyBinding> </runtime> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules> <remove name="ApplicationInsightsWebTracking" /> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> </modules> <rewrite> <rules> <rule name="HTTPS跳转" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> </compilers> </system.codedom> </configuration> |
是不是很简单?只需要添加节:
1 2 3 4 5 6 7 8 9 10 11 |
<rewrite> <rules> <rule name="HTTPS跳转" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> |
from:https://lebang2020.cn/details/210106t51nqtom.html
View DetailsQueryWrapper高级用法
QueryWrapper queryWrapper = new QueryWrapper<>(); 查询指定字段 通过select()查询指定字段,同时可对字段进行Mysql函数处理
1 |
queryWrapper.select("service_code as serviceCode", "sum(num) as num"); |
设置limit 通过last(),效果等同于limit
1 |
queryWrapper.last("limit 0,5"); |
查询条件中使用函数 例如,在查询IP时,想使用INET_ATON()函数,可以使用apply()实现
1 2 |
queryWrapper.apply("INET_ATON(qsip) <= INET_ATON({0})", ipQuery); queryWrapper.apply("INET_ATON(zzip) >= INET_ATON({0})", ipQuery); |
from:https://blog.csdn.net/qq_42594278/article/details/106625280
View Detailscentos系统swap设置 查看swap分区的方法
交换分区swap,意思是“交换”、“实物交易”,它的功能就是在内存不够的情况下,操作系统先把内存中暂时不用的数据,存到硬盘的交换空间,腾出内存来让别的程序运行,和Windows的虚拟内存(pagefile.sys)的作用是一样的。 查看 已存在的swap分区:
1 2 3 4 5 |
[root@iZ94hzx4xerZ bin]# swapon -s Filename Type Size Used Priority /mnt/swap file 10232 10184 -1 |
创建用于交换分区的文件:
1 2 3 4 5 6 7 |
[root@iZ94hzx4xerZ bin]# dd if=/dev/zero of=/mnt/swap bs=1024 count=10240 10240+0 records in 10240+0 records out 10485760 bytes (10 MB) copied, 0.237175 s, 44.2 MB/s |
bs=1024 指的是创建swap分区的初始大小,count指的是swap最大空间,推荐设置为内存的1-2倍。 设置交换分区文件:
1 2 3 4 5 6 7 8 9 |
[root@iZ94hzx4xerZ mnt]# mkswap /mnt/swap mkswap: /mnt/swap: warning: don't erase bootbits sectors on whole disk. Use -f to force. Setting up swapspace version 1, size = 2044 KiB no label, UUID=e6f0ae06-0e6b-4fce-8c18-d5a247b40259 |
立即启用交换分区文件:
1 |
[root@iZ94hzx4xerZ mnt]# swapon /mnt/swap |
设置开机时自启用swap分区: 需要修改文件/etc/fstab中的swap行。 添加 /mnt/swap swap swap defaults 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# # /etc/fstab # Created by anaconda on Thu Aug 14 21:16:42 2014 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=94e4e384-0ace-437f-bc96-057dd64f42ee / ext4 defaults,barrier=0 1 1 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 /mnt/swap swap swap defaults 0 0 |
设置后可以执行free -m命令或者top查看效果:
1 2 3 4 5 6 7 8 9 10 11 |
[root@iZ94hzx4xerZ bin]# top top - 20:33:11 up 4:53, 2 users, load average: 0.00, 0.00, 0.00 Tasks: 104 total, 1 running, 88 sleeping, 15 stopped, 0 zombie Cpu(s): 0.3%us, 0.2%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 1920740k total, 1845096k used, 75644k free, 38716k buffers Swap: 10232k total, 10184k used, 48k free, 260692k cached |
删除swap分区:
1 |
[root@iZ94hzx4xerZ bin]# swapon /mnt/swap |
from:https://www.laike.net/article-52-117134-0.html
View Detailskswapd CPU占用率过高
kswapd0 CPU占用率过高问题 解决方法:
1 2 3 4 5 6 7 8 |
top P #直接输入大写p #查看排在第一位的kswapd进程 cd /proc/进程id ls -l exe #查看软链真实目录 cd /var/tmp/..../.nva/ #进入软链真实目录 rm -rf * #删除软链目录下所有文件 kill -9 进程id |
kswapd是linux中用于页面回收的内核线程。页面回收,并不是回收得越多越好,而是力求达到一种balanced。因为页面回收总是以cache丢弃、内存swap、等为代价的,对系统性能会有一定程度的影响。 原因:kswapd0 占用过高也是物理内存不足所引起的 kswapd0 占用过高是因为 物理内存不足,使用swap分区与内存换页操作交换数据,导致CPU占用过高。swap分区的作用是当物理内存不足时,会将一部分硬盘当做虚拟内存来使用。 可以通过修改/proc/sys/vm/swappiness(也可以用find查找这个文件)里面的数值来修改swap分区使用与否,默认 60,数值越大表示更多的使用swap分区 swap 分区和内存都有缓存区,缓存的内容为之前使用过的数据,用于加快第二次打开时访问速度。 swap分区可以使用多个交换区(使用多硬盘?) 来加快swap访问速度 swap 分区使用的为硬盘的内容,速度比直接访问内存慢几千倍 拓展: Cache:高速缓存,是位于CPU与主内存间的一种容量较小但速度很高的存储器。 Buffer:缓冲区,一个用于存储速度不同步的设备或优先级不同的设备之间传输数据的区域。通过缓冲区,可以使进程之间的相互等待变少,从而使从速度慢的设备读入数据时,速度快的设备的操作进程不发生间断。 通俗点就是 cache是高速缓存,用于CPU和内存之间的缓冲; buffer是I/O缓存,用于内存和硬盘的缓冲 from:https://blog.csdn.net/weixin_45546960/article/details/124266481
View DetailsSpringBoot定时任务 @Scheduled详解
博主在最近的开发中又遇到了关于定时调度的开发任务,在定时调度其实有很多的第三方平台可以接入,但是其实在SpringBoot有自带的定时任务注解@Scheduled。@Scheduled可以通过注解配置快速实现方法的定时调度,直接在方法加上@Scheduled注解即可。 一.@Scheduled注解参数 1.cron参数 这个参数是最经常使用的参数,表示接收一个cron参数,cron它是一个表达式,最多接收7个参数,从左到右分别表示:秒 分 时 天 月 周 年;参数以空格隔开,其中年不是必须参数,可以省略。
1 2 3 4 5 6 7 8 |
/** * cron 一共可以有7个参数 以空格分开 其中年不是必须参数 * [秒] [分] [小时] [日] [月] [周] [年] * 一下表示 */ @Scheduled(cron ="0 0 0 * * * ?") public void testScheduledCron(){ } |
注意!!! 在使用时需要在类上添加注解@EnableScheduling,表示开启定时任务。 cron参数意义: 序号 含义 是否必填 入参范围 可填通配符 1 秒 是 0-59 , – * / 2 分 是 0-59 , – * / 3 时 是 0-23 , – * / 4 日 是 1-31 , – * ? / L W 5 月 是 1-12 , – * / 6 周(周一 ~ 周日) 是 1-7 , – * ? / L # 8 年 否 1970-2099 , – * / 常用通配符: *:表示所有值 比如用在日 表示每一天。 ?:表示不指定值 比如周配置 […]
View DetailsJava中QueryWrapper的基本使用
1.单表查询
1 2 3 4 5 6 7 8 9 |
@GetMapping("/list") public TableDataInfo list(Student student){ LambdaQueryWrapper<Student> lqw = new LambdaQueryWrapper<Student>(); lqw.eq(Student::getName, student.getName()); lqw.like(Student::getClass,student.getClass()); lqw.between("age",student.getAge1(),student.getAge2()); lqw.orderByAsc("age"); List<Student> list = studentService.list(lqw); } |
对应的sql语句为:
1 |
select * from student where name = '?' and class like '%?%' and age between '?' and '?' order by '?' asc |
1.1、单表查询的基本用法 函数名 说明 例子 eq 等于 例:eq(“name”,“张子”) ===> name = ‘张子’ ne 不等于 例:ne(“name”,“张子”) ===> name <> ‘张子’ gt 大于 例:gt(“age”,“18”) ===> age>18 lt 小于 例:lt(“age”,“18”) ===> age<18 between 在值1到值2之间 例:between(“age”,18,30) ===> 18<age<30’ like 模糊查询 例:like(“name”,“张”) ===> name like ‘%张%’ isNull 字段为NULL 例:isNull(“name”) ===> name is null 2、多表查询
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
//Controller @GetMapping("/listAndClass") public TableDataInfo listAndClass(Student student) { QueryWrapper<Student > qw = new QueryWrapper<Student >(); if(StringUtils.isNotBlank(student.getName())){ qw.eq("s.name",student.getName()); } if(StringUtils.isNotBlank(student.getClassName())){ qw.like("c.name",student.getClassName()); } startPage(); List<Student > list = studentService.listAndClass(qw); return getDataTable(list); } //Service List<Student> listAndClass(QueryWrapper<Student> qw); //Service impl @Override public List<Student> listAndClass(QueryWrapper<Student> qw) { return this.getBaseMapper().listAndClass(qw); } //Mapper @Select("select s.*,c.name from student s left join class c on s.id = c.student_id "+ "${ew.customSqlSegment}") List<YwSpaqjgDj> listAndClass(@Param(Constants.WRAPPER) QueryWrapper<Student> qw); |
from:https://www.cnblogs.com/gongss/p/16727090.html
View Detailsfastjson的日期格式化
//SerializerFeature.WriteDateUseDateFormat 使用日期字段格式序列化(2017-01-01),而不是用时间戳表示日期 JSON.toJSONString(data, SerializerFeature.WriteDateUseDateFormat)); from:https://www.cnblogs.com/gossip/p/6963957.html
View DetailsMaven单、多仓库配置
1. 单独仓库配置 打开Maven配置文件 apache-maven-3.6.3\conf\settings.xml 在<mirrors></mirrors>标签里新增一个mirror配置即可。
1 2 3 4 5 6 7 8 |
<mirrors> <mirror> <id>aliyun</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> |
标签 作用 id 镜像的唯一标识 name 名称描述 url 地址 mirrorOf 指定镜像规则,什么情况下从镜像仓库拉取 mirrorOf规则 作用 * 匹配所有,所有内容都从镜像拉取 external:* 除了本地缓存的所有从镜像仓库拉取 central 覆盖默认的仓库 repo1,repo2 匹配仓库repo1和repo2,使用逗号分割多个远程仓库 比如:镜像配置的规则 <mirrorOf>repo1</mirrorOf>,意为:匹配到目标仓库 <id>repo1</id>; 所以maven认为目标仓库central被镜像了; 不再去 https://repo.maven.apache.org/maven2/ 地址下载jar包; 而是去镜像仓库 http://maven.aliyun.com/nexus/content/groups/public/ 下载jar包。 2. 多仓库配置 有时候我们需要的jar包公有仓库没有,此时就必须启用多仓库配置,使maven同时使用私有仓库和公有仓库。 在<profiles></profiles>标签里配置多个profile配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<profiles> <profile> <id>aliyun-repo</id> <repositories> <repository> <id>aliyun</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>jboss-repo</id> <repositories> <repository> <id>jboss</id> <url>http://repository.jboss.org/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>maven-repo</id> <repositories> <repository> <id>maven2</id> <url>http://central.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profiles> |
在<activeProfiles></activeProfiles>标签里使用<activeProfile></activeProfile>标签启用配置。
1 2 3 4 5 |
<activeProfiles> <activeProfile>aliyun-repo</activeProfile> <activeProfile>jboss-repo</activeProfile> <activeProfile>maven-repo</activeProfile> </activeProfiles> |
from:https://www.aliang.link/pages/df2aeb/#_2-%E5%A4%9A%E4%BB%93%E5%BA%93%E9%85%8D%E7%BD%AE
View DetailsCentOS7 执行yum 命令出错 One of the configured repositories 如何解决
新安装的一台云服务器, 执行yum命令出现了错误, One of the configured repositories failed (Unknown), 最后是Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again 。完整的错误信息是: 这里重点是最后一行 for repository: epel/x86_64. 说明是这个仓储出了问题。 解决办法1 删除这个仓库
1 |
rm -f mv /etc/yum.repos.d/epel.repo |
这样执行yum命令就可以正确的执行。不过少了 epel 仓库好多软件包不能用。 这里介绍 第二种解决方法 查看了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
cat /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 7 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 |
然后测试了一下网络
1 2 3 4 |
[root@lampfree.com ~]# ping download.fedoraproject.org ping: download.fedoraproject.org: Name or service not known [root@lampfree.com ~]# ping mirrors.fedoraproject.org ping: mirrors.fedoraproject.org: Name or service not known |
发现网络不通,这里就需要解决网络问题。 修改dns cat /etc/resolv.conf
1 2 |
nameserver 8.8.8.8 nameserver 8.8.4.4 |
from:https://blog.csdn.net/b_o_n_z_t_f/article/details/121195667
View Details