以下是我的代碼。 if和else語句都被執行。有人能幫我解決這個問題嗎?if和else語句都在while循環中執行
Statement st = con.createStatement();
String sql = "Select Attribute from attribute";
ResultSet rs = st.executeQuery(sql);
while(rs.next()) {
if(Message.contains(rs.getString("Attribute")) || Subject.contains(rs.getString("Attribute")) == true) {
response.sendRedirect("User_Send.jsp?auth=1");
} else {
Statement st2 = con.createStatement();
String query = "insert into Message(Username,REmail,Subject,Message,Date,Status) values('"+ Username +"','" + To + "','" + Subject + "','" + Message + "','" + Date + "','" + "Done" + "')";
int i = st2.executeUpdate(query);
if(i!=0) {
out.println("<h1 style='text-align:center;color:Red'>Message Sent Successfully</h1>");
}
}
}
您嘗試調試此問題嗎? – TheLostMind
您是否重新啓動日食? –
是的,我試過了。 – Career