我在构建Spring + Spring MVC + Hibernate + MySQL项目时遇到了问题.
一切正常但是当我得到"editpage"然后想要将编辑信息发布到MySQL时,我从我的Tomcat收到以下错误:
HTTP Status 400 - Required Integer parameter 'id' is not present
Run Code Online (Sandbox Code Playgroud)
控制器类
@RequestMapping(value = "/users/edit", method = RequestMethod.POST)
public String saveEdit(@ModelAttribute("userAttribute") User user,
@RequestParam(value = "id", required =
true)Integer id, Model model){
logger.debug("Received request to update person");
user.setId(id);
personService.edit(user);
model.addAttribute("id", id);
return "editedpage";
}
Run Code Online (Sandbox Code Playgroud)
服务类
public void edit(User user){
logger.debug("Editing existing user");
Session session = sessionFactory.getCurrentSession();
User existingUser = (User) session.get(User.class, user.getId());
existingUser.setLogin(user.getLogin());
existingUser.setPassword(user.getPassword());
existingUser.setReal_name(user.getReal_name());
session.save(existingUser);
}
Run Code Online (Sandbox Code Playgroud)
我的JSP页面
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" …Run Code Online (Sandbox Code Playgroud) 这是cmd错误,我不明白错误在哪里,我一次又一次地碰到它,无法解决它。
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Preparing master VM for linked clones...
default: This is a one time operation. Once the master VM is prepared,
default: it will be used as a base for linked clones, making the creation
default: of new VMs take milliseconds on a modern system.
==> default: Importing base box 'hashicorp/bionic64'...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and …Run Code Online (Sandbox Code Playgroud) 我是Spring和Hibernate的新手,我正在开发电子商务管理系统,我的麻烦在于使用Hibernate将文件上传到DB中.我有一些服务,但我发现它不起作用.
这是我的代码
域
@Entity
@Table(name = "DEPUTES_APPEAL")
public class DeputesAppeal implements Serializable {
@Id
@Column(name = "ID")
@GeneratedValue
private long id;
@Column(name = "NumberOfAppeal")
private Integer number;
@Column(name = "DateOfIncomingAppeal")
private Date IncomingDate;
@Column(name = "NameOfDepute")
private String NameOfDepute;
@Column(name = "ResolutionOfChief")
private String ResolutionOfChief;
@Column(name = "TypeOfAppeal")
private String typeOfAppeal;
@OneToMany(mappedBy = "deputesAppeal", cascade =
CascadeType.ALL, fetch= FetchType.EAGER)
private final Set<UploadFiles> fileUpload = new HashSet<UploadFiles>
();
public DeputesAppeal(){}
public DeputesAppeal(int id, int number, Date incomingDate, String
nameOfDepute, String resolutionOfChief) …Run Code Online (Sandbox Code Playgroud) 我在Spring + Spring MVC + Hibernate + MySQL Web应用程序中遇到Spring配置问题.Spring无法创建我在Service类中宣布的bean.
这是Controller类
@Controller
@RequestMapping("/main")
public class MainController {
private static Logger LOGGER = Logger.getLogger("Controller");
@Autowired
private PersonServiceImpl personServiceImpl;
@Autowired
private ActionServiceImpl actionServiceImpl;
@RequestMapping(value = "/users" , method = RequestMethod.GET)
public String getUsers(Model model) {
LOGGER.debug("Receive request for show all users");
List<User> users = personServiceImpl.getAll();
model.addAttribute("users", users);
return "userspage";
}
@RequestMapping(value = "/users/add", method = RequestMethod.GET)
public String getAdd() {
LOGGER.debug("Receive request to show add page");
return "addpage";
}
@RequestMapping(value = "/users/add", method …Run Code Online (Sandbox Code Playgroud)