SSM图书信息管理系统参考网上的代码,然后修改了一个星期


SSM图书信息管理系统.zip
资源截图
代码片段和文件信息
package com.shuangyulin.controller;

import java.beans.PropertyEditorSupport;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.shuangyulin.utils.UserException;

public class baseController {



@InitBinder
// 必须有一个参数WebDataBinder
public void initBinder(WebDataBinder binder) {
//System.out.println(binder.getFieldDefaultPrefix());
binder.registerCustomEditor(Date.class new CustomDateEditor(
new SimpleDateFormat(“yyyy-MM-dd“) false));
 
binder.registerCustomEditor(Integer.class new PropertyEditorSupport() {
@Override
public String getAsText() { 
return (getValue() == null) ? ““ : getValue().toString();

@Override
public void setAsText(String text) {
Integer value = null;
if (null != text && !text.equals(““)) {  
try {
value = Integer.valueOf(text);
} catch(Exception ex)  { 
throw new UserException(“数据格式输入不正确!“); 
}  
}
setValue(value);

});
  
//binder.registerCustomEditor(Integer.class nullnew CustomNumberEditor(Integer.class null true));

binder.registerCustomEditor(Float.class new PropertyEditorSupport() {
@Override
public String getAsText() { 
return (getValue() == null)? ““ : getValue().toString();

@Override
public void setAsText(String text)  {
Float value = null;
if (null != text && !text.equals(““)) {
try {
value = Float.valueOf(text);
} catch (Exception e) { 
throw new UserException(“数据格式输入不正确!“); 
}
}
setValue(value);
}
});
}
 
/** 
 * 处理图片文件上传,返回保存的文件名路径
 * fileKeyName: 图片上传表单key
 * @throws IOException 
 * @throws IllegalStateException 
 */ 
public String handlePhotoFileUpload(HttpServletRequest requestString fileKeyName) throws IllegalStateException IOException {
String fileName = “upload/NoImage.jpg“;
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; 
        /**构建图片保存的目录**/    
        String photoBookPathDir = “/upload“;     
        /**得到图片保存目录的真实路径**/    
        String photoBookRealPathDir = request.getSession().getServletContext().getRealPath(photoBookPathDir);     
        /**根据真实路径创建目录**/    
        File photoBookSaveFile = new File(photoBookRealPathDir);     
        if(!photoBookSaveFile.exists())     
         photoBookSaveFile.mkdirs();           
        /**页面控件的文件流**/    
        MultipartFile multipartFile_photoBook = multipartRequest.getFile(fileKeyName);    
        if(!m

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-10 14:19  SSM图书信息管理系统
     文件        3627  2018-01-10 14:19  SSM图书信息管理系统.classpath
     目录           0  2018-01-10 14:18  SSM图书信息管理系统.myeclipse
     文件         315  2018-01-10 14:19  SSM图书信息管理系统.mymetadata
     文件        1420  2018-01-10 14:19  SSM图书信息管理系统.project
     目录           0  2018-01-10 14:19  SSM图书信息管理系统.settings
     文件         500  2018-01-10 14:19  SSM图书信息管理系统.settings.jsdtscope
     文件         104  2018-01-10 14:19  SSM图书信息管理系统.settingscom.genuitec.eclipse.core.prefs
     文件         197  2018-01-10 14:19  SSM图书信息管理系统.settingsorg.eclipse.core.resources.prefs
     文件         330  2018-01-10 14:19  SSM图书信息管理系统.settingsorg.eclipse.jdt.core.prefs
     文件          49  2018-01-10 14:19  SSM图书信息管理系统.settingsorg.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-01-10 14:19  SSM图书信息管理系统.settingsorg.eclipse.wst.jsdt.ui.superType.name
     目录           0  2018-01-10 14:19  SSM图书信息管理系统config
     文件         319  2018-01-10 14:19  SSM图书信息管理系统configjdbc.properties
     文件         329  2018-01-10 14:19  SSM图书信息管理系统configlog4j.properties
     目录           0  2018-01-10 14:19  SSM图书信息管理系统configmybatis
     文件         648  2018-01-10 14:19  SSM图书信息管理系统configmybatissqlMapConfig.xml
     目录           0  2018-01-10 14:19  SSM图书信息管理系统configspring
     文件        2443  2018-01-10 14:19  SSM图书信息管理系统configspringapplicationContext-dao.xml
     文件        1317  2018-01-10 14:19  SSM图书信息管理系统configspringapplicationContext-service.xml
     文件        2370  2018-01-10 14:19  SSM图书信息管理系统configspringapplicationContext-transaction.xml
     文件        3054  2018-01-10 14:19  SSM图书信息管理系统configspringspringmvc.xml
     目录           0  2018-01-10 14:19  SSM图书信息管理系统mysql数据库脚本
     文件        3110  2018-01-10 14:19  SSM图书信息管理系统mysql数据库脚本ook_db.sql
     目录           0  2018-01-10 14:19  SSM图书信息管理系统src
     目录           0  2018-01-10 14:19  SSM图书信息管理系统srccom
     目录           0  2018-01-10 14:19  SSM图书信息管理系统srccomshuangyulin
     目录           0  2018-01-10 14:19  SSM图书信息管理系统srccomshuangyulincontroller
     文件        4007  2018-01-10 14:19  SSM图书信息管理系统srccomshuangyulincontrolleraseController.java
     文件       10637  2018-01-10 14:19  SSM图书信息管理系统srccomshuangyulincontrollerBookController.java
     文件        6446  2018-01-10 14:19  SSM图书信息管理系统srccomshuangyulincontrollerBookTypeController.java
............此处省略245个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)