Я новичок в Spring MVC & Boot. Я могу открыть http://localhost:8088/postList, но при ошибке http://localhost:8088/post/1 я испытываю ошибку страницы ошибки Whitelabel. Я не могу найти свою ошибку. Вы можете это сказать?Spring MVC возвращает 404 из-за неправильного имени представления InternalResourceViewResolver
Моя структура проекта
Мой InternalResourceViewer:
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("WEB-INF/views/");
resolver.setSuffix(".jsp");
return resolver;
}
Мой контроллер:
@Controller
@RequestMapping("/")
public class PostController
{
@Autowired
PostService postService;
@RequestMapping(value="/post/{id}", method=RequestMethod.GET)
public ModelAndView list(@PathVariable("id") int id){
ModelAndView mav=new ModelAndView("post");
Post postItem=postService.getPostById(id);
mav.addObject("postItem",postItem);
mav.addObject("postItem",postItem);
return mav;
}
@RequestMapping(value="/postList", method=RequestMethod.GET)
public ModelAndView postlist(){
ModelAndView mav=new ModelAndView("postList");
mav.addObject("postList",postService.listPosts());
return mav;
}
}
Мой PostList:
Мои сообщения страница просмотра:
Мои postList.jsp и содержание библиотеки тегов:
<div class="row"> <c:if test="${not empty postList}"> <c:forEach var="postItem" items="${postList}"> <div class="col-lg-8"> <h1><a href="<c:url value='/post/${postItem.id}' />">${postItem.header}</a></h1> <p class="lead"> by <a href="#">${postItem.user_id}</a> </p> <p><span class="glyphicon glyphicon-time"></span>${postItem.upddate}</p> <hr> </div> </c:forEach> </c:if>
Покажите нам содержимое 'postList.jsp' со ссылками. –