36. 线程和进程的区别?
答:一个应用程序就是一个进程,在windows上这些进程表面上看都是并发的,实际上他们并不是同一时刻运行。可以一边在微信聊天,一边打开音乐播放器。操作系统为每一个进程分配一个PCB。进程具有的特征:动态性、并发性、独立性、异步性。进程的三种状态:就绪态、执行态、阻塞态。同一进程中,线程切换是不会引起进程切换。售票系统总的100张票共享资源,现在开4个窗口相当于4个线程。
37. 说说查询某功能的流程?
1) jsp+servlet+ajax查询学生成绩信息的前后端交互
答:首先加载scoreList.jsp页面,发送ajax异步请求,获取学生和课程数据json字符串。调用web层StudentServlet的method=StudentList和CourseServlet的method=CourseList,通过request.getParameter接收参数,返回list集合。通过parseInt转为java对象。调用dao层StudentList方法返回student对象的集合,执行sql语句 select * from student,执行query方法返回resultset结果集返回到web层,通过response.getWriter响应json数据,遍历集合数据,展示classlist.jsp页面。
2)jsp+servlet增加一条学生记录
答:首先加载studentlist.jsp页面,发送ajax异步请求获取json字符串的value值。调用web层StudentServlet的method=addStudent,通过request.getParameter接收属性username、password等参数。通过parseInt转为java对象,调用dao层method=addStudent,执行sql语句insert into student values (?, ?),返回update方法执行executeQuery方法,返回web层,通过response.getWriter().write响应json数据展示studentList.jsp页面。
3) spring+html视图+http请求查询医生信息的前后端交互
答:首先在客户端浏览器输入url加载index.html页面,发送http请求通过@Controller实例化web层的类,@RequestMapping(“/doctor”)注解请求映射到医生,通过@Autowired注入到doctorservice实现类复写findAll方法,返回list集合,调用dao层,通过@Respository实例化bean执行exxcutequery方法返回list集合,返回web层通过注解@ResponseBody , @PathVariable响应泛型是doctor的list集合,展示index.html页面。
4)spring+html视图+http请求增加一条医生的记录
答:在客户端浏览器输入url加载doctorForm.html页面,发送http请求通过注解@Controller,@RequestMapping(“/doctor”)实例化controller层doctor对象,通过@Autowired注解注入doctorservice层通过注解@Service实例化doctor,复写inserdoctor方法,通过@Autowired注解注入到doctordao层,通过注解@Respository实例化dao层的doctor,执行insert方法,返回web层通过注解@ResponseBody响应泛型是doctor的responseresult的响应结果。