0

I'm experimenting with Spring a bit. With use of Spring Boot I have prepared an application that allows basic CRUD operations on my entity objects.

I have tested it in two ways - first by writing a standard Controller:

@Controller
public class AdminController
{
    @Autowired
    private UserDAO userDao;

    @RequestMapping(value={"admin", "admin/list"})
    public String list(Model m)
    {
        List<User> users;
        users = (List<User>) userDao.findAll();
        m.addAttribute("users", users);
        return "admin/index";
    }

    (...)

}

With Thymeleaf-flavoured views - working like a charm

Secondly, I've written RESTful resource with Jersey:

@Path("/user")
public class UserResource
{
    @Autowired
    private UserDAO userDao;

    @POST
    @Path("/list")
    @Produces("application/json")
    public List<User> list()
    {
        List<User> users;
        users = (List<User>) userDao.findAll();
        return users;
    }

    (...)

}

That's also working, but... not together. Once I have My UserResource registered in JerseyConfiguration - I cannot access the standard controller anymore. When I comment out the registration of resource - the REST resources cease to respond, but the controller and the views are accessible again.

Why is it happening so? What am I missing?

khartvin
  • 551
  • 1
  • 7
  • 20

0 Answers0