Implement a Next article

Article page up and down to display the title

@GetMapping (value = "newsDetail" )
     public String newsDetail (the Model Model, @RequestParam (value = "NID" ) String NID) 
    { 
        News n- = newsService.findOne (Long.valueOf (nId.trim ()));
         IF ( ! n-= null ) { 
            List <News> NewsList = newsService.listAll (); 
        // determines whether there is an element contains()
iF (newsList.size ()! = 0 ) { int index = newsList.indexOf (n-); // current news for the first time, the last one on a News upperNews = newsList.get (index == 0 newsList.size () - 1: index-1? ); // current news as the last one, the next will be the first to News lowerNews = newsList.get (index == newsList.size () - 1 0: index + 1? ); Model.addAttribute ( "upperNews" , upperNews ); model.addAttribute ( "lowerNews" , lowerNews); model.addAttribute ( "News" , n-); return the this .render ( "newsDetail" ); } } return the this .render ( "index" ); }

 

Guess you like

Origin www.cnblogs.com/ssjf/p/11307818.html
Recommended