![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Java其他
奚学长又装死
这个作者很懒,什么都没留下…
展开
-
Servlet生成JSP页面验证码
1、JSP页面调用后台的Servlet页面来生成验证码JSP页面部分代码,点击验证码图片能够刷新验证码: function Refresh() { document.getElementById("ImgCode").src="servlet/ImgCodeServlet?now="+new Date(); }原创 2015-11-26 13:56:16 · 540 阅读 · 0 评论 -
getRequestDispatcher 与 sendRedirect 的区别
1.服务器内部的跳转,可以将需要的参数放到request里,带值跳转 List<Object[]> list = comm.findSchools(); request.setAttribute("schoolList", list); request.getRequestDispatcher(Constant.bin...原创 2016-04-06 16:10:54 · 284 阅读 · 0 评论 -
SnowFlake生成的ID,用FreeMarker在前台展示丢失精度的处理
1.后台的属性类型是long,前台展示时需要(用?c)进行格式化,否则会显示为:100,000,000这种带逗号分隔的形式<input type="hidden" id="petdId" name="petdId" value="${((testDomainPO.petdId)?c)!''}"/>2.后台的属性类型是String ,前台往后台传参数时,需要加引号,否则会丢失...原创 2018-08-24 11:20:39 · 1092 阅读 · 0 评论 -
java 深拷贝与浅拷贝
1.浅拷贝第一种可以用 import org.apache.commons.beanutils.PropertyUtils; 这个工具类PoolFttbVO dest=new PoolFttbVO();//第一个参数为拷贝结果,第二个参数为 源拷贝对象PropertyUtils.copyProperties(dest,orig);第二种,对象实现Cloneable接口,并原创 2017-10-09 09:56:24 · 285 阅读 · 0 评论 -
get请求表单的action属性后不能带参数
最近在编写网页程序时,有类似如下代码: 不过我发现在后台获取参数时,一直获取不到表单action中的method参数值controller=message&method=search后经查询发现,浏览器会将表单数据封装为字符串,如controller=mes转载 2016-10-26 13:52:07 · 410 阅读 · 0 评论 -
Calendar日期处理
1.获取当前时间前一小时Date nowTime = new Date(); //当前时间 Date beforeTime = new Date(); Calendar calendar = Calendar.getInstance(); //得到日历 calendar.setTime(nowTime); //把当前时间赋给日历原创 2016-06-17 16:39:28 · 313 阅读 · 0 评论 -
文件转换成byte[]数组 / byte[]生成文件
以下:/** * * * @param sZipPath * @return * @see [类、类#方法、类#成员] */ private byte[] changeFileToByte(String sZipPath) { byte[] buffer = null; try原创 2016-06-17 15:34:10 · 7136 阅读 · 0 评论 -
AES CBC模式加密/解密
密钥:/** * AES密钥 */ private final String m_sKey = ""; /** * AES 加密向量 */ private final String m_sIV = "";以下:/** * * * @param src 待加密的byte[]原创 2016-06-17 15:38:24 · 1653 阅读 · 0 评论 -
文件夹压缩成.zip格式
压缩:需要用到 org.apache.tools.ant.taskdefs.Zip 相应的包自行下载/** * * * @param sDirPath 待压缩的文件夹 * @param sZipPath 压缩后的zip文件路径 * @see [类、类#方法、类#成员] */ private void creat原创 2016-06-17 15:28:09 · 666 阅读 · 0 评论 -
XML字符串转换成XML Document对象,并生成在指定路径
以下:/** * * * @param sXml * @return * @see [类、类#方法、类#成员] */ public Document changeStringToXML(String sXml) { StringReader sr = new StringReader(sXml);原创 2016-06-17 14:52:55 · 4637 阅读 · 0 评论 -
获得tomcat文件夹的路径
以下:/** * * * @return * @see [类、类#方法、类#成员] */ public String getPath() { //当前盘符路径,会获得tomcat/bin文件夹所在的路径 File file = new File(""); String path原创 2016-06-17 14:15:23 · 3145 阅读 · 2 评论 -
java 前台传入后台乱码
有多种解决方案1.String strUTF8 = new String(contractNo.getBytes("ISO8859-1"),"UTF-8");2.使用form表达post提交,提交的参数为contractNo3.如果是get方式提交,提交的参数需 encodeURI(encodeURI(contractNo)) (两次编码)解析时一次解析 URLDecoder....原创 2018-11-09 17:06:05 · 257 阅读 · 0 评论