Merge branch 'master' of C:\Users\zhai_\Documents\GDMS with conflicts.

zgl
zhai_lw 6 years ago
parent a96fc2bb1a
commit 3c1d9b6906

@ -7,6 +7,9 @@
<element id="directory" name="classes">
<element id="module-output" name="GDMS" />
</element>
<element id="directory" name="lib">
<element id="file-copy" path="C:/Program Files/apache-tomcat-9.0.13/lib/tomcat-jdbc.jar" />
</element>
</element>
</root>
</artifact>

@ -0,0 +1,46 @@
package servlet.account;
import core.user.User;
import core.user.utils.AccountManagement;
import error.GExcptAccount;
import error.GExcptSQL;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
public class S_Register extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
Map<String,String> user_info=new HashMap<>();
String id=request.getParameter("id");
user_info.put("id",id);
String name=request.getParameter("name");
user_info.put("name",name);
String e_mail=request.getParameter("e-mail");
user_info.put("e_mail",e_mail);
String phone_number=request.getParameter("phone-number");
user_info.put("phone_number",phone_number);
String password=request.getParameter("password");
user_info.put("password",password);
User user=null;
try {
user = AccountManagement.register("student",user_info);
} catch (GExcptSQL gExcptSQL) {
gExcptSQL.printStackTrace();
} catch (GExcptAccount gExcptAccount) {
gExcptAccount.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
//注册失败
request.getSession().setAttribute("User",user);
request.getRequestDispatcher("/home.jsp").forward(request,response);
}
}

@ -0,0 +1,50 @@
package servlet.basic_settings;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebFilter(filterName = "sessionFilter",urlPatterns = {"/*"})
public class S_Filter implements Filter {
String NO_LOGIN="/notLogin";
String includeUrls="/gdms/login.jsp";
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException,IOException{
HttpServletRequest request=(HttpServletRequest) servletRequest;
HttpServletResponse response=(HttpServletResponse) servletResponse;
HttpSession session=request.getSession(false);
String uri=request.getRequestURI();
//是否需要过滤
boolean needFilter=isNeedFilter(uri);
if(!needFilter){
filterChain.doFilter(servletRequest,servletResponse);
}else{
//需要过滤器
//session中包含user对象则是登录状态
if(session!=null&&session.getAttribute("user")!=null){
filterChain.doFilter(servletRequest,servletResponse);
}else{
String requestType=request.getHeader("X-Requested-with");
//判断是否是ajax请求
if(requestType!=null&&"XMLHttpRequest".equals(requestType)){
response.sendRedirect(NO_LOGIN);
}else{
//重定向到登录页(需要在static文件夹下建立此html文件)
response.sendRedirect("/gdms/login.jsp");
}
return;
}
}
}
public boolean isNeedFilter(String uri) {
if (includeUrls.equals(uri)) {
return false;
}
return true;
}
}

@ -0,0 +1,24 @@
package servlet.select;
import core.process.C_StudentSearchTeacher;
import core.process.C_StudentSelectTeacher;
import core.user.User;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class S_StudentSelectTeacher extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
String student_id=request.getParameter("id");
User user=(User)request.getSession().getAttribute("User");
String teacher_id=user.getId();
try {
new C_StudentSelectTeacher().select(student_id,teacher_id);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,24 @@
package servlet.select;
import core.process.C_TeacherSelectStudent;
import core.user.User;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class S_TeacherSelectStudent extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
String teacher_id=request.getParameter("id");
User user=(User)request.getSession().getAttribute("User");
String student_id=user.getId();
try {
new C_TeacherSelectStudent().select(teacher_id,student_id);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -56,7 +56,7 @@
<select class="id-check" name="usertype">
<option value="">身份</option>
<option value="student">学生</option>
<option value="teacher">老师</option>
<option v alue="teacher">老师</option>
</select>
<input class="register-submit-style" type="submit" value="注册">
</form>

@ -25,7 +25,7 @@
<div class="select-blank"></div>
<div class="selected-bottom"></div>
</div>
<div class="list-frame bar-change">
<div class="list-frame bar-hange">c
<div class="list-child">
<div class="name"><span class="the-name">李先生</span></div>
<div class="other-msgs">

Loading…
Cancel
Save