사용자가 ID로 사용자를 검색하고 페이지에서 할당 된 모듈을 검색합니다. 필자는 모델에서 일대 다 관계를 매핑했습니다.Spring @PathVariable은 HTTP 상태를 반환합니다. 404
사용자 모델
@Entity
@Table(name = "user")
@Component
public class User implements Serializable
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="user")
private Set<Module> sModule = new HashSet<Module>();
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="manager")
private Set<Module> cModule = new HashSet<Module>();
모듈 모델 그것을 위해
@Entity
@Table(name = "modules")
@Component
public class Module implements Serializable
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="user_id", insertable=false, updatable=false)
private User user;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="manager_id", insertable=false, updatable=false)
private User manager;
컨트롤러 -
@RequestMapping(value="/home/user_page/{userId}", method =
RequestMethod.GET)
public String showUserModules(@PathVariable("userId") String userId, ModelMap
map, HttpServletRequest request) {
map.addAttribute("cp", request.getContextPath());
map.addAttribute("user", userService.getWithModules(userId));
return "/home/user_page";}
나는 그것이 오류를 보여주는 반환 user_page 열려고 :
The requested resource is not available
을
사용자 페이지로 갈 때 어떻게 사용자와 필요한 모듈을 얻을 수 있습니까?
편집 : 스택 트레이스
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP
request with URI [/professional/home/user_page] in DispatcherServlet
with name 'servlet-context'
안녕하세요. 이 오류가 발생하면 어떤 URL을 사용합니까? – dimas
실제 스택 추적이란 무엇입니까? – Bart
안녕하세요, stacktrace를 첫 번째 게시물에 추가했습니다. URI가있는 HTTP 요청에 대해 매핑이 없다는 경고가 한 줄로 표시되었습니다. – user2259555