我正在使用JSP为主题库做一个litle项目。 当最终用户查看本书的书籍和评级详情时,我想为图书馆中的书籍创建评级系统。 任何人都可以给出提示或教程如何解决这个问题?
I'm doing one litle project with JSP for topic Library. I want to create a rating system for books in library when end-user view detail of book and rating for this book. Can anyone give hints or tutorials how to go about this?
最满意答案
我建议使用jQuery Star Rating插件 。 检查演示页面的样子。 JSP / HTML基本上看起来像这样(你只需要在公共webcontent中放入必要的JS / CSS /图像文件)。 魔术是通过给单选名称star的单选按钮完成的。
<!DOCTYPE html> <html lang="en"> <head> <title>Star rating demo</title> <link rel="stylesheet" href="jquery.rating.css"> <script src="jquery.js"></script> <script src="jquery.rating.js"></script> </head> <body> <form> <input type="radio" name="rating" value="1" class="star"> <input type="radio" name="rating" value="2" class="star"> <input type="radio" name="rating" value="3" class="star"> <input type="radio" name="rating" value="4" class="star"> <input type="radio" name="rating" value="5" class="star"> </form> </body> </html>在服务器端,您只需使用HttpServletRequest#getParameter()来获取评级值。
String rating = request.getParameter("rating"); // ...通过上面的例子,它将返回1,2,3,4或5。
I'd suggest to use the jQuery Star Rating plugin for this. Check the demo page how it all look like. The JSP/HTML basically look like this (you only need to put the necessary JS/CSS/image files in the public webcontent). The magic is done by giving the radio buttons the class name star.
<!DOCTYPE html> <html lang="en"> <head> <title>Star rating demo</title> <link rel="stylesheet" href="jquery.rating.css"> <script src="jquery.js"></script> <script src="jquery.rating.js"></script> </head> <body> <form> <input type="radio" name="rating" value="1" class="star"> <input type="radio" name="rating" value="2" class="star"> <input type="radio" name="rating" value="3" class="star"> <input type="radio" name="rating" value="4" class="star"> <input type="radio" name="rating" value="5" class="star"> </form> </body> </html>In the server side you just use HttpServletRequest#getParameter() to obtain the rating value.
String rating = request.getParameter("rating"); // ...With the above example, it'll return 1, 2, 3, 4 or 5.
更多推荐
发布评论