Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post article前进行验证码验证,以确保不是机器所为。 #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions WZF_OAPS.iml

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/java/com/javaBeans/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;

/**
* Servlet implementation class com.javaBeans.Controller
Expand Down Expand Up @@ -297,6 +298,16 @@ else if(page.equals("comments_dislike"))

if(page.equals("post-article"))
{
String code = (String) request.getSession().getAttribute("verifyCodeValue");
String textCode = request.getParameter("verifyCode");
if (!code.equals(textCode)) {
request.getSession().setAttribute("info","验证码输入不正确!");
try {
request.getRequestDispatcher("NewFile.jsp").forward(request, response);
} catch (ServletException | IOException e) {
e.printStackTrace();
}
}
String subject = request.getParameter("subject");
String email = request.getParameter("email");

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/javaBeans/UploadServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;
import javax.swing.*;


import com.database.DB;
Expand Down Expand Up @@ -49,6 +50,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t


protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

Part filePart = request.getPart("file");
response.setContentType("text/plain;charset=UTF-8");
String author = request.getParameter("author");
Expand Down
Loading