JSP技术:if标签

 

<c:if> 与我们在一般程序中用的if一样

 

test9_login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="http://127.0.0.1:8080/U9/test9_index.jsp" method="post">
用户名: <input type="text" name="uname">
密码:   <input type="password" name="upwd">
<input type="submit">
</body>
</html>

test9_index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String name=request.getParameter("uname");
String pwd=request.getParameter("upwd");
request.setAttribute("name", name);
request.setAttribute("pwd", pwd);
%>
<c:if test="${requestScope.name=='admin' && requestScope.pwd=='123' }">
${requestScope.name}登录成功
</c:if>
</body>
</html>

 

阅读剩余
THE END