Reputation: 750
I want to know what parts of my web page the users use and then present it in a nice graphic interface. The only thing I could come up with was this:
@Controller
public class WebController {
@Autowired
private DatabaseResource dbr;
@RequestMapping("/foobar")
public String getFoobar(Principal principal, ModelMap model, HttpServletRequest req) {
dbr.logVisit(req); //write the request to a database
//...
At each @RequestMapping I write the request to the database. Is this the best way to do it?
Does it exists a library for this so I do not have to write it all my self? A package that works a bit like Eclipse Usage Data Collector.
I'm using Spring and Spring Security.
Upvotes: 0
Views: 1620
Reputation: 340993
Write a custom HandlerInterceptor
, this feature is specificaly designed to implement features like this.
Another approach is to use Logback Access that tightly and seamlessly integrates with Tomcat.
Upvotes: 1