1、在Tomcat的Webapps目录下建立一个目录
源代码在线查看: addcomment.jsp
String uid = (String)session.getAttribute("UID");
String queryString = request.getQueryString();
decodeQueryString.setQueryString(queryString);
String filename = decodeQueryString.getQueryStringValue("filename");
String content = request.getParameter("content");
String title = request.getParameter("title");
Comment comment = new Comment();
comment.setContent(content);
comment.setFileName(filename);
comment.setUser(uid);
commnetAdmin.setRootPath(application.getRealPath("/data/"));
if (commnetAdmin.add(comment)) {
//添加成功,重新显示留言页面
response.sendRedirect("photodetails.jsp?filename="+filename+
"&title="+title);
} else {
out.print("相片评论");
out.print("");
out.print(" CommentAdmin:添加相片评论 }
%>