首页>代码>java servlet+hibernate通过Ajax实现的简单成绩查询项目实例>/成绩查询/scoreSearch/src/com/hfm/servlet/StudentServlet.java
package com.hfm.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hfm.dao.StudentDao;
import com.hfm.dao.impl.StudentDaoImpl;
import com.hfm.entity.Student;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONUtils;

@SuppressWarnings("serial")
public class StudentServlet extends HttpServlet {

	private StudentDao stuDao = new StudentDaoImpl();

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("application/json;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		String stuNo = request.getParameter("stuNo");
		List<Student> students = stuDao.getbyStuNo(stuNo);
		JSONObject object = new JSONObject(); 
		object.put("result", students);
		response.getWriter().print(object);
//		request.setAttribute("student", students);
		
	}
}
最近下载更多
huaua7676  LV30 2021年7月20日
阳止初四  LV8 2021年6月6日
MIAOHUA  LV6 2021年2月27日
network_sec  LV6 2020年11月14日
j45254fdad  LV1 2020年9月8日
xiaochen873  LV8 2020年7月27日
2109716825  LV1 2020年6月5日
1355862436  LV9 2020年5月12日
jaonsang  LV25 2020年2月25日
alphastar  LV6 2020年1月10日
最近浏览更多
vilychan  LV2 2023年9月11日
liang85  LV1 2023年6月30日
gwl18289332687 2023年1月14日
暂无贡献等级
kman404  LV1 2022年11月23日
周敏国  LV9 2022年10月31日
微信网友_6186189978783744 2022年10月22日
暂无贡献等级
微信网友_6040315240812544  LV8 2022年10月20日
憨豆先生  LV2 2022年5月12日
吸一口月光 2021年12月15日
暂无贡献等级
dafqrf  LV1 2021年12月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友