src/com/marry/controller/TypeController.java
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.marry.controller;
import com.marry.entity.Type;
import com.marry.entity.User;
import com.marry.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller
@RequestMapping("type")
public class TypeController {
@Autowired
private TypeService typeService;
@ModelAttribute
public String path(HttpServletRequest request){
return request.getServletPath();
}
@RequestMapping("list")
public String list(Model model, HttpSession session,String index){
List<Type> list=typeService.selectList();
model.addAttribute("list",list);
User user= (User) session.getAttribute("login");
if (!StringUtils.isEmpty(index)) return index;
if (user!=null && user.getRole()==1){
model.addAttribute("type","active");
return "manage/typeList";
}else {
return "type";
}
}
@RequestMapping("update")
public String update(Type type,Model model,MultipartFile file,HttpServletRequest request) throws IOException {
if (!file.isEmpty()){
String path = request.getSession().getServletContext().getRealPath("/upload/images");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmssSSS");
String fileName = sdf.format(new Date());
String imgUrl = path + "\\" + fileName + file.getOriginalFilename();
File filePath = new File(imgUrl);
if (!filePath.getParentFile().exists()) {
filePath.getParentFile().mkdirs();
}
file.transferTo(filePath);
后面还有 45 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。