use of com.service.MovieInfoService in project Movie by batsqd.
the class SearchMovieController method showSearchContent.
@RequestMapping("/showSearchContent.action")
public ModelAndView showSearchContent(String keyWord) throws UnsupportedEncodingException {
//防止中文乱码
String decode_keyWord = URLDecoder.decode(keyWord, "UTF-8");
System.out.println("decode_keyWord" + decode_keyWord);
System.out.println("keyWord" + keyWord);
ModelAndView modelAndView = new ModelAndView();
MovieInfoService movieInfoService = new MovieInfoService();
ArrayList<Movie> moviesList = new ArrayList<Movie>();
int pageCount = 0;
if (decode_keyWord != null) {
//search box提交的请求
moviesList = movieInfoService.getMoviesBySearchKeyWordToPage(decode_keyWord, 0, 12);
pageCount = movieInfoService.getPageCountByKeyWord(12, decode_keyWord);
}
if (pageCount > 1) {
//此时有下一页
modelAndView.addObject("navigation", "<a href='http://yuanzhiyuan-pc:8080/Movie/getSearchMovieByPage.action?pageNow=1&keyWord=" + URLEncoder.encode(URLEncoder.encode(decode_keyWord, "UTF-8"), "UTF-8") + "'>下一页</a>" + " 共" + pageCount + "页!");
}
modelAndView.addObject("moviesList", moviesList);
modelAndView.setViewName("/WEB-INF/jsp/ShowSearchResult.jsp");
return modelAndView;
}
use of com.service.MovieInfoService in project Movie by batsqd.
the class SearchMovieController method getSearchMovieByPage.
@RequestMapping("/getSearchMovieByPage.action")
public ModelAndView getSearchMovieByPage(int pageNow, String keyWord) throws UnsupportedEncodingException {
int pageSize = 12;
int pageCount = 1;
int begain = 0;
int end = 5;
begain = (pageNow) * pageSize;
end = begain + pageSize;
//防止中文乱码
String decode_keyWord = URLDecoder.decode(keyWord, "UTF-8");
MovieInfoService movieInfoService = new MovieInfoService();
ArrayList<Movie> moviesList = movieInfoService.getMoviesBySearchKeyWordToPage(decode_keyWord, begain, end);
pageCount = movieInfoService.getPageCountByKeyWord(pageSize, decode_keyWord);
ModelAndView modelAndView = new ModelAndView();
String navigationUrlPre = "";
String navigationUrlNext = "";
if (pageNow < 1) {
//没有上一页;
navigationUrlPre = "";
} else {
//有上一页
navigationUrlPre = "<a href='http://yuanzhiyuan-pc:8080/Movie/getSearchMovieByPage.action?pageNow=" + (pageNow - 1) + "&keyWord=" + URLEncoder.encode(URLEncoder.encode(decode_keyWord, "UTF-8"), "UTF-8") + "'>上一页</a>";
}
if (pageNow + 1 < pageCount) {
//有下一页
navigationUrlNext = "<a href='http://yuanzhiyuan-pc:8080/Movie/getSearchMovieByPage.action?pageNow=" + (pageNow + 1) + "&keyWord=" + URLEncoder.encode(URLEncoder.encode(decode_keyWord, "UTF-8"), "UTF-8") + "'>下一页</a>";
} else {
//没有下一页
navigationUrlNext = "";
}
modelAndView.addObject("moviesList", moviesList);
modelAndView.addObject("navigation", "当前为第" + (pageNow + 1) + "页 " + navigationUrlPre + " " + navigationUrlNext + " " + " 共" + pageCount + "页!");
modelAndView.setViewName("/WEB-INF/jsp/ShowSearchResult.jsp");
return modelAndView;
}
use of com.service.MovieInfoService in project Movie by batsqd.
the class FrameController method showRomance.
@RequestMapping("/romance.action")
public ModelAndView showRomance(String type, String genres) {
//type指的是按照流派,按照发行时间,按照评分
ModelAndView modelAndView = new ModelAndView();
MovieInfoService movieInfoService = new MovieInfoService();
ArrayList<Movie> moviesList = new ArrayList<Movie>();
int pageCount = 0;
if ("byGenres".equals(type)) {
moviesList = movieInfoService.getMoviesByGenresToPage(genres, 0, 12);
pageCount = movieInfoService.getPageCountByGenres(12, genres);
} else if ("byReleaseTime".equals(type)) {
//此处按发布时间指的是按照Romance类别中电影的发布时间顺序
moviesList = movieInfoService.getMoviesOrderByReleaseTimeToPage(genres, 0, 12);
pageCount = movieInfoService.getPageCountByGenres(12, genres);
} else if ("byRating".equals(type)) {
moviesList = movieInfoService.getMoviesOrderByRatingToPage(genres, 0, 12);
pageCount = movieInfoService.getPageCountByGenres(12, genres);
}
if (pageCount > 1) {
//此时有下一页
modelAndView.addObject("navigation", "<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow=1&type=" + type + "&genres=" + genres + "'>下一页</a>" + " 共" + pageCount + "页!");
}
modelAndView.addObject("genres", genres);
modelAndView.addObject("moviesList", moviesList);
//genres=romance,所有的类型都可以调到同一个页面
modelAndView.setViewName("/WEB-INF/jsp/romance.jsp");
return modelAndView;
}
use of com.service.MovieInfoService in project Movie by batsqd.
the class FenyeController method getMoviesByPage.
@RequestMapping("/getMoviesByPage.action")
public ModelAndView getMoviesByPage(int pageNow, String type, String genres) {
//pageNow是指用户从所看到的页面的那页
int pageSize = 12;
int pageCount = 1;
int begain = 0;
int end = 5;
begain = (pageNow) * pageSize;
end = begain + pageSize;
ArrayList<Movie> moviesList = new ArrayList<Movie>();
MovieInfoService movieInfoService = new MovieInfoService();
if ("byGenres".equals(type)) {
moviesList = movieInfoService.getMoviesByGenresToPage(genres, begain, end);
pageCount = movieInfoService.getPageCountByGenres(pageSize, genres);
} else if ("byReleaseTime".equals(type)) {
moviesList = movieInfoService.getMoviesOrderByReleaseTimeToPage(genres, begain, end);
pageCount = movieInfoService.getPageCountByGenres(pageSize, genres);
} else if ("byRating".equals(type)) {
moviesList = movieInfoService.getMoviesOrderByRatingToPage(genres, begain, end);
pageCount = movieInfoService.getPageCountByGenres(pageSize, genres);
}
ModelAndView modelAndView = new ModelAndView();
String navigationUrlPre = "";
String navigationUrlNext = "";
if (pageNow < 1) {
//没有上一页;
navigationUrlPre = "";
} else {
//有上一页
/*http://121.42.174.147:8080
navigationUrlPre="<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow="+(pageNow-1)+"&type="+type+"&genres="+genres+"'>上一页</a>";
*/
navigationUrlPre = "<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow=" + (pageNow - 1) + "&type=" + type + "&genres=" + genres + "'>上一页</a>";
}
if (pageNow + 1 < pageCount) {
//有下一页
navigationUrlNext = "<a href='http://yuanzhiyuan-pc:8080/Movie/getMoviesByPage.action?pageNow=" + (pageNow + 1) + "&type=" + type + "&genres=" + genres + "'>下一页</a>";
} else {
//没有下一页
navigationUrlNext = "";
}
modelAndView.addObject("genres", genres);
modelAndView.addObject("moviesList", moviesList);
modelAndView.addObject("navigation", "当前为第" + (pageNow + 1) + "页 " + navigationUrlPre + " " + navigationUrlNext + " " + " 共" + pageCount + "页!");
modelAndView.setViewName("/WEB-INF/jsp/romance.jsp");
return modelAndView;
}
Aggregations