我一直在阅读Spring MVC HandlerMapping,HandlerAdapter但我对这两个概念感到困惑.我可以理解HandlerMapping用于将传入的HTTP请求映射到控制器但what is the use of HandlerAdapter?why do we use it?what is the exact difference between these two with example?
请帮助我.谢谢!!
我是HIbernate的新手,正在练习一对多映射的一些例子,但我不知道它为什么会抛出错误.
1)Employee.java
package com.common.pojo;
import java.util.Set;
public class Employee
{
private int id;
private String name;
private Set certificate;
public Employee (){}
public Employee(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set getCertificate() {
return certificate;
}
public void setCertificate(Set certificate) {
this.certificate = certificate;
}
}
Run Code Online (Sandbox Code Playgroud)
2)Certificate.java …
我是Spring MVC的新手,面临一些错误.
我有两个控制器如下
1)LoginController.java
@Controller
@RequestMapping("/log")
public class LoginController {
@Autowired
private LoginService service;
@RequestMapping(value="login.spring",method=RequestMethod.GET)
public ModelAndView prepareLoginForm()
{
System.out.println("In get");
return new ModelAndView("Login", "login", new Login());
}
@RequestMapping(value="login.spring",method=RequestMethod.POST)
public ModelAndView processLogin(@ModelAttribute("login") Login login,BindingResult result)
{
int i=service.validateLogin(login);
if(i==0){
return new ModelAndView("redirect:login.spring");
}
ModelAndView view=new ModelAndView("redirect:Customer/Searchform.spring");
return view;
}
}
Run Code Online (Sandbox Code Playgroud)
2) CustomerController.java
@Controller
@RequestMapping("/Customer")
public class CustomerController {
@Autowired
private CustomerService customerService;
@RequestMapping(value="Searchform.spring",method=RequestMethod.GET)
public ModelAndView prepareCustomer()
{
System.out.println("In customer controller");
CustomerSearchForm customerSearchForm=new CustomerSearchForm();
return new ModelAndView("CustomerSearch","customerSearchForm",customerSearchForm);
}
@RequestMapping(value="Search.spring",method=RequestMethod.POST)
public …Run Code Online (Sandbox Code Playgroud)