无法使用Spring Boot命中控制器

时间:2015-12-28 01:25:25

标签: java spring spring-mvc

任何人都可以帮助我,因为我无法点击我的某个网址的控制器。这是代码:

@Controller
@RequestMapping("/posts")
public class PostController {
    @Autowired
    private PostRepository repository;
    @RequestMapping(value = "", method = RequestMethod.GET)
    public String listPosts(Model model) {
        model.addAttribute("posts", repository.findAll());
        return "postList";
    }

    @RequestMapping(value = "/new", method = RequestMethod.GET)
    public String newProject() {
        return "newPost";
    }
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public ModelAndView create(@RequestParam("postDescription") String comment) {
        repository.save(new Posts());
        return new ModelAndView("redirect:/postList");
    }
    //...
}

和JSP:

<form action="<spring:url value="/posts/create" />">
     <div class="form-group">
     <label for="postDescription">Post</label>
     <button type="submit" id="save" class="btn btn-primary">Save</button>
</form>

我能够点击RegistrationController而不是PostController

我是否需要配置其他内容?

0 个答案:

没有答案