archieve: homework5 if.jsp

This commit is contained in:
2025-04-21 13:26:58 +08:00
parent 4763732388
commit 3bed589aab
4 changed files with 79 additions and 0 deletions
+10
View File
@@ -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>
+10
View File
@@ -24,6 +24,16 @@
<version>6.1.0</version>
<scope>provided</scope>
</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>
<groupId>org.junit.jupiter</groupId>
<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);
}
}
+32
View File
@@ -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>