JSP 파일 (서블릿을 사용하고 싶지는 않음)에서 작업하고 있는데, 간단한 양식, 2 개의 레이블, 2 개의 입력 및 2 버튼을 사용하여 제출 된 문자열 을 동일한 JSP 페이지에 인쇄하려고 할 때 문제는 새 값을 시도 할 때 제출 된 마지막 값이 화면에 인쇄 된 상태로 남아 있기 때문입니다.버튼이 눌러 졌는지 확인하는 방법 (JSP 파일에서)
<body>
<form method='post'>
<pre>
<label>Username</label> <input type="text" name="user" required/>
<label>Password</label> <input type="password" name="pwd" required />
<br>
<input type="submit" value="confirm" name ="submit" />
<input type="reset" value="clear" />
</pre>
</form>
<br>
// test if the submit button was clicked (check if value of submit is confirm)
<% String x=request.getParameter("submit")%>
<% if (x.equals("confirm")){ %>
<% if (request.getParameter("user")!="" && request.getParameter("pwd")!=""){ %>
<center>
<h4> user is : <% out.write(request.getParameter("user")); %> </h4>
<br>
<h4> password is : <% out.write(request.getParameter("pwd")); %> </h4>
</center>
<% } else { %>
<h4> inputs r empty !! </h4>
<% } %>
<% } %>
</body>
내가 줄에서 오류가 발생합니다 :
<% if (x.equals("confirm")){ %>
우리가 디스플레이로 이동하기 전에 버튼을 클릭 한 제출이 코드를 시도
이유가 무엇입니까?
감사합니다. – user2161721