1. 程式人生 > >controller層接收前臺jsp路徑傳來的id的實現(/{id})/@RequestMapping("/findCorporationInfo/{id}")

controller層接收前臺jsp路徑傳來的id的實現(/{id})/@RequestMapping("/findCorporationInfo/{id}")

 jsp頁面:

<a href="${pageContext.request.contextPath}/corporation/findCorporationInfo/${sessionScope.user.id}" style="text-align: center">個人資料</a>

controller:

@RequestMapping("/corporation")
@Controller
public class UserCompleteController {
    @Resource
    private UserCompleteService userCompleteService;

    @RequestMapping("/findCorporationInfo/{id}")
    public String findCorporationInfo(@PathVariable Integer id, HttpSession session){
        UserComplete userComplete = userCompleteService.findCorporationInfo(id);
        if(userComplete!=null){
            session.setAttribute("userComplete",userComplete);
            return "/personal/findCorporationInfo";
        }
        return "";
    }
}