archieve: homework5 if.jsp
This commit is contained in:
Generated
+10
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="WebContextManager">
|
||||||
|
<option name="state">
|
||||||
|
<map>
|
||||||
|
<entry key="file://$PROJECT_DIR$/src/main/webapp/if.jsp" value="file://$PROJECT_DIR$/src/main/webapp" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -24,6 +24,16 @@
|
|||||||
<version>6.1.0</version>
|
<version>6.1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet.jsp.jstl</groupId>
|
||||||
|
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.web</groupId>
|
||||||
|
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.msksbr.homework5;
|
||||||
|
|
||||||
|
import jakarta.servlet.RequestDispatcher;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@WebServlet(name="MyServlet", urlPatterns="/MyServlet")
|
||||||
|
public class MyServlet extends HttpServlet {
|
||||||
|
public void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) {
|
||||||
|
request.setAttribute("username", "msksbr");
|
||||||
|
request.setAttribute("password", "123456");
|
||||||
|
RequestDispatcher dispatcher=request.getRequestDispatcher("/my.jsp");
|
||||||
|
try {
|
||||||
|
dispatcher.forward(request, response);
|
||||||
|
} catch (ServletException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) {
|
||||||
|
doGet(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<fieldset>
|
||||||
|
<c:if test="${param.action=='mon'}">
|
||||||
|
周一了:工作的第一天,加油!
|
||||||
|
</c:if>
|
||||||
|
<c:if test="${param.action=='tues'}">
|
||||||
|
周二了:工作的第二天,加油!
|
||||||
|
</c:if>
|
||||||
|
<c:if test="${param.action=='wed'}">
|
||||||
|
周三了:工作的第三天,加油!
|
||||||
|
</c:if>
|
||||||
|
<c:if test="${param.action=='thu'}">
|
||||||
|
周四了:工作的第四天,加油!
|
||||||
|
</c:if>
|
||||||
|
<c:if test="${param.action=='fri'}">
|
||||||
|
周五了:工作的第五天,加油!
|
||||||
|
</c:if>
|
||||||
|
<c:if test="${param.action=='sat'}">
|
||||||
|
周六了:休息的第一天!
|
||||||
|
</c:if>
|
||||||
|
<c:if test="${param.action=='sun'}">
|
||||||
|
周日了:休息的第二天!
|
||||||
|
</c:if>
|
||||||
|
</fieldset>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user