![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Java
→→→→
这个作者很懒,什么都没留下…
展开
-
Js VS Java URL编码解码
背景描述: 项目经常需要在前端使用富文本编辑器,将编辑内容传递到后台;项目新加了防XSS攻击相关,会过滤一些特殊符号(<>;’"等),恰恰这些符号在富文本编辑器中常出现(html格式),所以想到了多富文本编辑器拿到的内容进行url编码,再到后台使用java解码,这样就可以保留住特殊符号;好啦,思路已明确,开干js对文本url编码console.log(encodeURI('<p><span style="font-weight: bold;">测试</sp原创 2020-05-15 11:39:48 · 600 阅读 · 0 评论 -
SpringMvc 转 SpringBoot 之打war包
SpringBoot默认本地是使用内嵌tomcat启动的,如果想要打war包传到服务器tomcat中,需要修改pom文件<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.o原创 2020-05-14 18:26:02 · 307 阅读 · 0 评论 -
Java Interceptor中使用HttpServletRequest
SpringMvc中web.xml 添加listener <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener>interceptor中注解注入request即可 @Autowired HttpServletRequest.原创 2020-05-13 18:29:43 · 617 阅读 · 0 评论 -
前端JS RSA加密,后端JAVA RSA解密
需求描述:用户网页登录,使用RSA对密码进行加密;加密串传到后台,后端查询用户注册的密码(RSA加密后的),对两个加密串RSA解密,解密后对比密码是否相同。参考https://github.com/travist/jsencrypthttps://www.jianshu.com/p/e19dc0b4fe78https://blog.csdn.net/weixin_43652442/article/details/87875491JS加密、JAVA解密,有两条路:根据jsencrypt步骤,原创 2020-05-11 18:21:55 · 1472 阅读 · 0 评论 -
SpringMvc + tomcat 设置大文件上传
springMvc配置 <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- one of the properties available; the maximum file size in bytes --> <property name="defaultEncoding原创 2020-05-09 17:43:57 · 263 阅读 · 0 评论 -
Java 读取配置文件
config.properties配置文件中的中文需要转码为unicodekey1 = value1key2 = value2key3 = value3\u8bed\u8a00 = \u4e2d\u6587xml.properties需要添加 dtd<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">&原创 2020-05-09 17:28:15 · 242 阅读 · 0 评论 -
JAVA 生成Excel/CSV 并上传到FTP服务器
首先配置好ftp服务器(windows + Serv-U)创建FtpUtilspublic class FTPUtils { private static FTPUtils ftpUtils; private FTPClient ftpClient; private String port; // 服务器端口 private String username; // 用户登录名 private String password; // 用户登录密码 pr原创 2020-05-09 17:23:55 · 4984 阅读 · 1 评论 -
JAVA使用POI生成EXCEL,并设置级联下拉列表
最近工作中时常有导出excel的需求,于是把常用到的生成Excel下拉列表相关方法汇总了下,常用到的分为三种单独下拉列表级联下拉列表根据选中的下拉列表自动填充单元格源码如下,欢迎大家指正、讨论。<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version&g原创 2020-05-09 17:19:23 · 6521 阅读 · 6 评论 -
SpringMVC 注解事务
在需要事务的方法上,添加注解 @Transactional添加配置 <!--事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> &l.原创 2020-05-09 17:15:57 · 1740 阅读 · 0 评论 -
根据已给出的webservice 定义,创建服务端接口
1. 使用soapUI 反向出接口定义好啦,接下来就可以把反向出的代码复制到项目中啦;代码中可能会有一些注解里面配了原有的包路径,需要改成现在项目中的包,不然启动可能会报错的。###2. pom引用 <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-bundle</artifactId> <version>2.0.10&原创 2020-05-09 17:14:18 · 360 阅读 · 0 评论 -
JAVA 发送邮件
import java.util.Properties;import javax.mail.Authenticator;import javax.mail.Message;import javax.mail.MessagingException;import javax.mail.PasswordAuthentication;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.Int原创 2020-05-09 17:12:47 · 150 阅读 · 0 评论 -
WebSocket 聊天
#前端页面<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <%@ include f.原创 2020-05-09 17:11:12 · 231 阅读 · 1 评论 -
SpringMVC + SpringBatch 注解方式
最近接触springbatch处理一些批量的业务数据,由于公司项目是SpringMvc架构,网上大部分SpringBatch都是和SpringBoot搭配使用的,在爬无数个坑后,记录下SpringMvc和SpringBatch搭配方式(ps:注解方式)。前提是您已然熟悉使用SpringMVC和SpringBatch。###1、创建纯粹的SpringMvc项目我用的是intellij,项目结构如图pom文件<?xml version="1.0" encoding="UTF-8"?>&原创 2020-05-09 17:10:10 · 1093 阅读 · 0 评论 -
i++和++i的区别
直接上两个网上很经典的demo例子1 int i = 1; int j = i++; System.out.println(i); System.out.println(j);答案:输出2和1直接反编译class文件,得到前两行的java指令,分析如下可以看出来,i++分为两iload和iinc,所以j=i++会先将i压入操作数栈,再对变量i自加,所以下一步操作从操作数栈取到的i是自加之前的。例子2 int i原创 2020-05-09 17:06:04 · 933 阅读 · 1 评论 -
spring 解决跨域问题
首先,如何在本机模拟跨域问题配置Hosts127.0.0.1 www.a.com www.b.com在线目中,添加测试页面,页面中发起ajax请求本项目接口,接口地址使用www.b.com域名使用www.a.com域名访问测试页面这样,就模拟了www.a.com 请求www.b.com ,发生跨域解决跨域问题,主要是在response中添加允许跨域的属性方式1,添加拦截器public boolean preHandle(HttpServletRequest request, HttpS原创 2020-05-09 17:03:07 · 330 阅读 · 0 评论 -
SpringMVC 配置http code返回值页面
web.xml 中配置errorPage<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.原创 2020-05-09 17:02:23 · 563 阅读 · 0 评论 -
SpringMvc项目配置根据环境自动读取不同的配置文件
将原有的配置文件拷贝一份,分别放在不同的文件夹内2.application-context.xml中读取配置文件的地方,引入变量<context:property-placeholder location="classpath:webserver/props/${spring.profiles.active}/*.properties"/>3.在启动项目时,指定变量值服务器中,修改tomcat/bin/catalina.sh...原创 2020-05-09 17:01:47 · 3133 阅读 · 0 评论 -
Spring MVC 传递参数的几种方式
一 ajax带简单参数请求controllerimport com.pandabus.framework.base.web.controller.BaseController;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;import org.spri原创 2020-05-09 16:18:19 · 854 阅读 · 0 评论 -
Java访问数据库通用帮助类
增删改的通用类import java.sql.*;public class DBHelper {/*** 获得connection* @return*/public Connection getConnection(){Connection c=null;try {Class.forName("com.mysql.jdbc.Drive原创 2013-08-08 15:45:57 · 520 阅读 · 0 评论