资源简介
美食相关网页,能够实现注册、登录、上传、查阅详情、搜索食谱等功能。需要有Tomcat、MySQL等工具,利用J2EE。
代码片段和文件信息
package database;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.jms.Session;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class add extends HttpServlet {
public void doGet(HttpServletRequest req HttpServletResponse resp)
throws ServletException IOException { // 处理post请求
this.doPost(req resp); // 同一种方法体处理
}
protected void doPost(HttpServletRequest request
HttpServletResponse response) throws ServletException IOException {
request.setCharacterEncoding(“utf8“);
response.setCharacterEncoding(“utf8“);
request.getParameter(“foodName“);
food fd=new food();
fd.setFoodName(request.getParameter(“foodName“));
fd.setClasses(request.getParameter(“type1“)+“;“+request.getParameter(“type2“));
fd.setPicture(request.getParameter(“picture“));
fd.setMessage(request.getParameter(“message“));
user usr = (user) request.getSession().getAttribute(“user“);
fd.setUpUser(usr.getUserName());
if(fd.check()){
request.getSession().setAttribute(“check“ “true“);
}
else
request.setAttribute(“check“ “false“);
response.sendRedirect(“uptest.jsp“);
}
}
评论
共有 条评论