基于javaweb+mysql的ssm教务学生管理成绩管理系统(java+ssm+jsp+jquery+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM教务学生管理成绩管理系统(java+ssm+jsp+jquery+mysql)
项目介绍
分为管理员、教师、学生
管理员角色包含以下功能: 管理员登录,修改个人资料,修改密码,用户管理,班级管理,科目管理,教务老师管理,任课老师管理,学生管理,成绩管理等功能。教师…
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7等版本均可;
技术栈
- 后端:Spring springmvc mybatis 2. 前端:JSP+css+javascript+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, User util, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
currentPageNo = Integer.parseInt(pageNo);
} catch (Exception e) {
}
List<User> list = userMapper.getObjectList(field, fieldValue);
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "User/find";
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
try {
userMapper.deleteObject(util.getId());
} catch (Exception e) {
}
}
return this.getAllUtil(request, util, model);
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, User util, Model model) {
try {
return "../login";
}
User user = userMapper.getObjectByName(util);
if (null == user) {
model.addAttribute("errMsg", "登录失败");
return "../login";
}
boolean flag = user.getS_1().equals(util.getS_1());
if (!flag) {
model.addAttribute("errMsg", "登录失败");
return "../login";
}
if (flag && !SysUtil.getSysFlag()) {
model.addAttribute("errMsg", "无法登陆,请联系管理员");
return "../login";
}
session.setAttribute("user_id", user.getId());
session.setAttribute("user_type", user.getS_11());
session.setAttribute("type1", "sys_admin");
session.setAttribute("type2", "sys_admin");
session.setAttribute("name", user.getS_2());
session.setAttribute("username", user.getS_0());
return "../index";
}
@RequestMapping(value = "/updatepwd.do")
public String updatepwd(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
User userTmp = userMapper.selectObject(user_id);
String oldPwd = util.getS_3();
String newPwd = util.getS_4();
String rePwd = util.getS_5();
if (null == oldPwd || "".equals(oldPwd) || null == newPwd
|| "".equals(newPwd) || null == rePwd || "".equals(rePwd)) {
model.addAttribute("errMsg", "密码信息不能为空");
model.addAttribute("util", userTmp);
return "User/updatepwd";
}
if (!newPwd.equals(rePwd)) {
model.addAttribute("errMsg", "确认密码不一致");
model.addAttribute("util", userTmp);
return "User/updatepwd";
}
if (newPwd.equals(oldPwd)) {
model.addAttribute("errMsg", "旧密码不能与新密码一致");
}
kemuMapper.updateObject(util);
}
return this.getAllUtil(request, model);
}
}
public class ActionEnter {
private HttpServletRequest request = null;
private String rootPath = null;
private String contextPath = null;
private String actionType = null;
private ConfigManager configManager = null;
public ActionEnter ( HttpServletRequest request, String rootPath ) {
this.request = request;
this.rootPath = rootPath;
this.actionType = request.getParameter( "action" );
this.contextPath = request.getContextPath();
this.configManager = ConfigManager.getInstance( this.rootPath, this.contextPath, request.getRequestURI() );
}
public String exec () {
}
public String invoke() {
if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) {
return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
}
if ( this.configManager == null || !this.configManager.valid() ) {
return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
}
State state = null;
int actionCode = ActionMap.getType( this.actionType );
Map<String, Object> conf = null;
switch ( actionCode ) {
case ActionMap.CONFIG:
return this.configManager.getAllConfig().toString();
case ActionMap.UPLOAD_IMAGE:
case ActionMap.UPLOAD_SCRAWL:
case ActionMap.UPLOAD_VIDEO:
case ActionMap.UPLOAD_FILE:
conf = this.configManager.getConfig( actionCode );
state = new Uploader( request, conf ).doExec();
break;
case ActionMap.CATCH_IMAGE:
conf = configManager.getConfig( actionCode );
String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) );
state = new ImageHunter( conf ).capture( list );
break;
case ActionMap.LIST_IMAGE:
case ActionMap.LIST_FILE:
conf = configManager.getConfig( actionCode );
model.addAttribute("listUser", listUser);
List<Bnaji> listBnaji = bnajiMapper.getObjectList(null, null);
model.addAttribute("listBnaji", listBnaji);
return "Student/saveOrUpdate";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try{
currentPageNo = Integer.parseInt(pageNo);
}catch(Exception e){
}
List<Student> list = studentMapper.getObjectList(field, fieldValue);
List<Student> listStudent = new ArrayList<Student>();
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
for (Student temp : list) {
if (user_id == temp.getUser().getId()) {
listStudent.add(temp);
}
}
if (!"admin".equals(user_type)) {
//list = listStudent;
}
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "Student/find";
}
@RequestMapping(value = "/deleteUtil.do")
return "Student/saveOrUpdate";
}
@RequestMapping(value = "/selectUtil.do")
public String selectUtil(HttpServletRequest request, Student util, Model model) {
util = studentMapper.selectObject(util.getId());
model.addAttribute("util", util);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
List<Bnaji> listBnaji = bnajiMapper.getObjectList(null, null);
model.addAttribute("listBnaji", listBnaji);
return "Student/saveOrUpdate";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try{
currentPageNo = Integer.parseInt(pageNo);
}catch(Exception e){
}
List<Student> list = studentMapper.getObjectList(field, fieldValue);
List<Student> listStudent = new ArrayList<Student>();
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
for (Student temp : list) {
if (user_id == temp.getUser().getId()) {
listStudent.add(temp);
}
}
if (!"admin".equals(user_type)) {
//list = listStudent;
}
try {
FileItemIterator iterator = upload.getItemIterator(request);
while (iterator.hasNext()) {
fileStream = iterator.next();
if (!fileStream.isFormField())
break;
fileStream = null;
}
if (fileStream == null) {
return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
}
String savePath = (String) conf.get("savePath");
String originFileName = fileStream.getName();
String suffix = FileType.getSuffixByFilename(originFileName);
originFileName = originFileName.substring(0,
originFileName.length() - suffix.length());
savePath = savePath + suffix;
long maxSize = ((Long) conf.get("maxSize")).longValue();
if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
}
savePath = PathFormat.parse(savePath, originFileName);
String physicalPath = (String) conf.get("rootPath") + savePath;
InputStream is = fileStream.openStream();
State storageState = StorageManager.saveFileByInputStream(is,
physicalPath, maxSize);
is.close();
if (storageState.isSuccess()) {
storageState.putInfo("url", PathFormat.format(savePath));
storageState.putInfo("type", suffix);
storageState.putInfo("original", originFileName + suffix);
userTmp.setS_1(newPwd);
userMapper.updateObject(userTmp);
return "User/uppwdok";
}
@RequestMapping(value = "/updateinfo.do")
public String updateinfo(HttpServletRequest request, User util, Model model) {
userMapper.updateObject(util);
model.addAttribute("util", util);
model.addAttribute("errMsg", "个人信息修改成功");
return "User/updateinfo";
}
@RequestMapping(value = "/beforepass.do")
public String beforepass(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
util = userMapper.selectObject(user_id);
model.addAttribute("util", util);
return "User/updatepwd";
}
@RequestMapping(value = "/beforeinfo.do")
public String beforeinfo(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
util = userMapper.selectObject(user_id);
model.addAttribute("util", util);
return "User/updateinfo";
}
@RequestMapping(value = "/register.do")
public String register(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
String code = (String) session.getAttribute("code");
String userCode = request.getParameter("code");
if (!code.equals(userCode)) {
model.addAttribute("errMsg", "验证码错误");
return "../register";
}
User user = userMapper.getObjectByName(util);
if (null != user) {
model.addAttribute("errMsg", "该用户名已经存在");
return "../register";
}
userMapper.insertObject(util);
model.addAttribute("registerMsg", "恭喜您,注册成功!");
return "../login";
}
@RequestMapping(value = "/initUtil.do")
public String initUtil(HttpServletRequest request, Model model) {
private String rootPath = null;
private String contextPath = null;
private String actionType = null;
private ConfigManager configManager = null;
public ActionEnter ( HttpServletRequest request, String rootPath ) {
this.request = request;
this.rootPath = rootPath;
this.actionType = request.getParameter( "action" );
this.contextPath = request.getContextPath();
this.configManager = ConfigManager.getInstance( this.rootPath, this.contextPath, request.getRequestURI() );
}
public String exec () {
String callbackName = this.request.getParameter("callback");
if ( callbackName != null ) {
if ( !validCallbackName( callbackName ) ) {
return new BaseState( false, AppInfo.ILLEGAL ).toJSONString();
}
return callbackName+"("+this.invoke()+");";
} else {
return this.invoke();
}
}
public String invoke() {
if ( actionType == null || !ActionMap.mapping.containsKey( actionType ) ) {
return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
}
if ( this.configManager == null || !this.configManager.valid() ) {
return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
}
State state = null;
}catch(Exception e){
}
List<Bnaji> list = bnajiMapper.getObjectList(field, fieldValue);
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "Bnaji/find";
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, Bnaji util, Model model) {
try{
bnajiMapper.deleteObject(util.getId());
}catch(Exception e){
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
try{
bnajiMapper.deleteObject(util.getId());
}catch(Exception e){}
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/saveOrUpdateObject.do")
public String saveOrUpdateObject(HttpServletRequest request, Bnaji util, Model model) {
List<Bnaji> list = bnajiMapper.getObjectList("s_0", util.getS_0());
if (0 == util.getId()) {
if (list.size() > 0) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "Bnaji/saveOrUpdate";
}
bnajiMapper.insertObject(util);
} else {
if (list.size() > 1) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "Bnaji/saveOrUpdate";
}
@Controller
@RequestMapping(value = "Kemu")
public class KemuController {
@Autowired
private KemuMapper kemuMapper;
@RequestMapping(value = "/initUtil.do")
public String initUtil(HttpServletRequest request, Model model) {
return "Kemu/saveOrUpdate";
}
@RequestMapping(value = "/selectUtil.do")
public String selectUtil(HttpServletRequest request, Kemu util, Model model) {
util = kemuMapper.selectObject(util.getId());
model.addAttribute("util", util);
return "Kemu/saveOrUpdate";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try{
return "RenkeLaoshi/find";
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, RenkeLaoshi util, Model model) {
try{
renkeLaoshiMapper.deleteObject(util.getId());
}catch(Exception e){
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
try{
renkeLaoshiMapper.deleteObject(util.getId());
}catch(Exception e){}
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/saveOrUpdateObject.do")
public String saveOrUpdateObject(HttpServletRequest request, RenkeLaoshi util, Model model) {
List<RenkeLaoshi> list = renkeLaoshiMapper.getObjectList("s_0", util.getS_0());
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
List<Bnaji> listBnaji = bnajiMapper.getObjectList(null, null);
model.addAttribute("listBnaji", listBnaji);
if (0 == util.getId()) {
if (list.size() > 0) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "RenkeLaoshi/saveOrUpdate";
}
renkeLaoshiMapper.insertObject(util);
} else {
if (list.size() > 1) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "RenkeLaoshi/saveOrUpdate";
}
renkeLaoshiMapper.updateObject(util);
}
return this.getAllUtil(request, model);
}
}
@Controller
@RequestMapping(value = "RenkeLaoshi")
public class RenkeLaoshiController {
@Autowired
private RenkeLaoshiMapper renkeLaoshiMapper;
@Autowired
private UserMapper userMapper;
@Autowired
private BnajiMapper bnajiMapper;
@RequestMapping(value = "/initUtil.do")
public String initUtil(HttpServletRequest request, Model model) {
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
List<Bnaji> listBnaji = bnajiMapper.getObjectList(null, null);
model.addAttribute("listBnaji", listBnaji);
return "RenkeLaoshi/saveOrUpdate";
}
@RequestMapping(value = "/selectUtil.do")
public String selectUtil(HttpServletRequest request, RenkeLaoshi util, Model model) {
util = renkeLaoshiMapper.selectObject(util.getId());
model.addAttribute("util", util);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
List<Bnaji> listBnaji = bnajiMapper.getObjectList(null, null);
model.addAttribute("listBnaji", listBnaji);
return "RenkeLaoshi/saveOrUpdate";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
@Autowired
private BnajiMapper bnajiMapper;
@RequestMapping(value = "/initUtil.do")
public String initUtil(HttpServletRequest request, Model model) {
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
List<Bnaji> listBnaji = bnajiMapper.getObjectList(null, null);
model.addAttribute("listBnaji", listBnaji);
return "RenkeLaoshi/saveOrUpdate";
}
@RequestMapping(value = "/selectUtil.do")
public String selectUtil(HttpServletRequest request, RenkeLaoshi util, Model model) {
util = renkeLaoshiMapper.selectObject(util.getId());
model.addAttribute("util", util);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
List<Bnaji> listBnaji = bnajiMapper.getObjectList(null, null);
model.addAttribute("listBnaji", listBnaji);
return "RenkeLaoshi/saveOrUpdate";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try{
currentPageNo = Integer.parseInt(pageNo);
}catch(Exception e){
}
List<RenkeLaoshi> list = renkeLaoshiMapper.getObjectList(field, fieldValue);
List<RenkeLaoshi> listRenkeLaoshi = new ArrayList<RenkeLaoshi>();
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
for (RenkeLaoshi temp : list) {
if (user_id == temp.getUser().getId()) {
listRenkeLaoshi.add(temp);
}
}
if (!"admin".equals(user_type)) {
//list = listRenkeLaoshi;
}
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try{
currentPageNo = Integer.parseInt(pageNo);
}catch(Exception e){
}
List<Chengji> list = chengjiMapper.getObjectList(field, fieldValue);
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "Chengji/find";
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, Chengji util, Model model) {
try{
chengjiMapper.deleteObject(util.getId());
}catch(Exception e){
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
try{
chengjiMapper.deleteObject(util.getId());
}catch(Exception e){}
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/saveOrUpdateObject.do")
public String saveOrUpdateObject(HttpServletRequest request, Chengji util, Model model) {
List<Chengji> list = chengjiMapper.getObjectList("s_0", util.getS_0());
List<Student> listStudent = studentMapper.getObjectList(null, null);
model.addAttribute("listStudent", listStudent);
List<Kemu> listKemu = kemuMapper.getObjectList(null, null);
model.addAttribute("listKemu", listKemu);
if (0 == util.getId()) {
if (list.size() > 0) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return new BaseState( false, AppInfo.INVALID_ACTION ).toJSONString();
}
if ( this.configManager == null || !this.configManager.valid() ) {
return new BaseState( false, AppInfo.CONFIG_ERROR ).toJSONString();
}
State state = null;
int actionCode = ActionMap.getType( this.actionType );
Map<String, Object> conf = null;
switch ( actionCode ) {
case ActionMap.CONFIG:
return this.configManager.getAllConfig().toString();
case ActionMap.UPLOAD_IMAGE:
case ActionMap.UPLOAD_SCRAWL:
case ActionMap.UPLOAD_VIDEO:
case ActionMap.UPLOAD_FILE:
conf = this.configManager.getConfig( actionCode );
state = new Uploader( request, conf ).doExec();
break;
case ActionMap.CATCH_IMAGE:
conf = configManager.getConfig( actionCode );
String[] list = this.request.getParameterValues( (String)conf.get( "fieldName" ) );
state = new ImageHunter( conf ).capture( list );
break;
case ActionMap.LIST_IMAGE:
case ActionMap.LIST_FILE:
conf = configManager.getConfig( actionCode );
int start = this.getStartIndex();
state = new FileManager( conf ).listFile( start );
break;
}
return state.toJSONString();
}
public int getStartIndex () {
String start = this.request.getParameter( "start" );
try {
return Integer.parseInt( start );
public class BinaryUploader {
public static final State save(HttpServletRequest request,
Map<String, Object> conf) {
FileItemStream fileStream = null;
boolean isAjaxUpload = request.getHeader( "X_Requested_With" ) != null;
if (!ServletFileUpload.isMultipartContent(request)) {
return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
}
ServletFileUpload upload = new ServletFileUpload(
new DiskFileItemFactory());
if ( isAjaxUpload ) {
upload.setHeaderEncoding( "UTF-8" );
}
try {
FileItemIterator iterator = upload.getItemIterator(request);
while (iterator.hasNext()) {
fileStream = iterator.next();
if (!fileStream.isFormField())
break;
fileStream = null;
}
if (fileStream == null) {
return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
}
String savePath = (String) conf.get("savePath");
currentPageNo = Integer.parseInt(pageNo);
}catch(Exception e){
}
List<JiaowuLaoshi> list = jiaowuLaoshiMapper.getObjectList(field, fieldValue);
List<JiaowuLaoshi> listJiaowuLaoshi = new ArrayList<JiaowuLaoshi>();
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
for (JiaowuLaoshi temp : list) {
if (user_id == temp.getUser().getId()) {
listJiaowuLaoshi.add(temp);
}
}
if (!"admin".equals(user_type)) {
//list = listJiaowuLaoshi;
}
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "JiaowuLaoshi/find";
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, JiaowuLaoshi util, Model model) {
try{
jiaowuLaoshiMapper.deleteObject(util.getId());
}catch(Exception e){
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
try{
jiaowuLaoshiMapper.deleteObject(util.getId());
}catch(Exception e){}
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/saveOrUpdateObject.do")
public String saveOrUpdateObject(HttpServletRequest request, JiaowuLaoshi util, Model model) {
List<JiaowuLaoshi> list = jiaowuLaoshiMapper.getObjectList("s_0", util.getS_0());
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
if (0 == util.getId()) {