<a href="${pageContext.request.contextPath}/pattern/bookAction.action"> 测试</a><br>

本文展示了如何在Struts框架中使用动态方法调用和通配符映射实现URL路由,通过示例代码演示了不同场景下的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
访问BookAction_add 测试action标签中的method属性<br>
<a href="${pageContext.request.contextPath}/pattern/bookAction.action"> 测试</a><br>
<br>
<br>


通配符映射示例(1):<br>
<a href="${pageContext.request.contextPath}/pattern/a_add.action"> 通配符映射示例(1)</a><br>
<a href="${pageContext.request.contextPath}/pattern/b_add.action"> 通配符映射示例(1)</a><br>
<a href="${pageContext.request.contextPath}/pattern/c_add.action"> 通配符映射示例(1)</a><br>
<br>
<br>
<br>

通配符映射示例(2):<br>
<a href="${pageContext.request.contextPath}/pattern/BookAction_add.action"> 图书</a><br>
<a href="${pageContext.request.contextPath}/pattern/UserAction_add.action">用户</a><br>
<br>
<br>

通配符映射示例(3):<br>
<a href="${pageContext.request.contextPath}/pattern/BookAction_add.action">图书添加</a><br>
<a href="${pageContext.request.contextPath}/pattern/BookAction_delete.action">图书删除</a><br>
<br>
<br>
<a href="${pageContext.request.contextPath}/pattern/UserAction_add.action">用户添加</a><br>
<a href="${pageContext.request.contextPath}/pattern/UserAction_delete.action">用户删除</a><br>
<br>
<br>


动态方法调用!形式:<br>
<a href="${pageContext.request.contextPath}/pattern/BookAction!add.action">图书添加</a><br>
<a href="${pageContext.request.contextPath}/pattern/BookAction!delete.action">图书删除</a><br>


<br><br>
使用通配符定义action<br>
<a href="${pageContext.request.contextPath}/pattern/BookAction_add.action">图书添加</a><br>
<a href="${pageContext.request.contextPath}/pattern/BookAction_delete.action">图书删除</a><br>

<br><br>
测试全局和局部的action<br>
<a href="${pageContext.request.contextPath}/pattern/BookAction_find.action">图书查询</a><br>

</body>
</html>
<%-- Created by IntelliJ IDEA. User: vili Date: 2019/8/23 Time: 13:42 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@page isELIgnored="false" %> <!--header--> <div class="header"> <div class="container"> <nav class="navbar navbar-default" role="navigation"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <h1 class="navbar-brand"><a href="index.action">叮当书城</a></h1> </div> <!--navbar-header--> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li><a href="index.action" <c:if test="${param.flag==1}">class="active"</c:if>>首页</a></li> <li class="dropdown"> <a href="#" class="dropdown-toggle <c:if test="${param.flag==2}">active</c:if>" data-toggle="dropdown">商品分类<b class="caret"></b></a> <ul class="dropdown-menu multi-column columns-2"> <li> <div class="row"> <div class="col-sm-12"> <h4>商品分类</h4> <ul class="multi-column-dropdown"> <li><a class="list" href="booktypes_list.action?pageNumber=1&btid=-1">全部系列</a></li> <c:forEach items="${bookTypes}" var="t"> <li><a class="list" href="booktypes_list.action?pageNumber=1&btid=${t.btid}">${t.btname}</a></li> </c:forEach> </ul> </div> </div> </li> </ul> </li> <li><a href="recommend_books.action?rtype=2&pageNumber=1" <c:if test="${param.flag==3 && t==2}">class="active"</c:if>>热销</a></li> <li><a href="recommend_books.action?rtype=3&pageNumber=1" <c:if test="${param.flag==3 && t==3}">class="active"</c:if>>新品</a></li> <c:choose> <c:when test="${empty user }"> <li><a href="user_register.jsp" <c:if test="${param.flag==10 }">class="active"</c:if>>注册</a></li> <li><a href="user_login.jsp" <c:if test="${param.flag==9 }">class="active"</c:if>>登录</a></li> </c:when> <c:otherwise> <li><a href="order_list.action" <c:if test="${param.flag==5 }">class="active"</c:if>>我的订单</a></li> <li><a href="user_center.jsp" <c:if test="${param.flag==4 }">class="active"</c:if>>个人中心</a></li> <li><a href="logout.action" >退出</a></li> <li><a href="admin/index.jsp" target="_blank">后台管理</a></li> </c:otherwise> </c:choose> </ul> <!--/.navbar-collapse--> </div> <!--//navbar-header--> </nav> <div class="header-info"> <div class="header-right search-box"> <a href="javascript:;"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></a> <div class="search"> <form class="navbar-form" action="search_books.action"> <input type="hidden" name="pageNumber" value="1"/> <input type="text" class="form-control" name="keyword"> <button type="submit" class="btn btn-default <c:if test="${param.flag==7 }">active</c:if>" aria-label="Left Align">搜索</button> </form> </div> </div> <div class="header-right cart"> <a href="book_cart.jsp"> <span class="glyphicon glyphicon-shopping-cart <c:if test="${param.flag==8 }">active</c:if>" aria-hidden="true"><span class="card_num"><c:choose><c:when test="${empty order}">0</c:when><c:otherwise>${order.itemMap.size()}</c:otherwise></c:choose></span></span> </a> </div> <div class="clearfix"> </div> </div> <div class="clearfix"> </div> </div> </div> <!--//header-- 修改代码使后台管理标签能跳转到后台管理页面
最新发布
06-20
这是我的表结构: DROP TABLE IF EXISTS `animalphotos`; CREATE TABLE `animalphotos` ( `photo_id` int NOT NULL AUTO_INCREMENT COMMENT ' 照片ID', `animal_id` int NULL DEFAULT NULL COMMENT ' 所属动物ID', `photo_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '图片路径或URL', PRIMARY KEY (`photo_id`) USING BTREE, INDEX `animal_id`(`animal_id` ASC) USING BTREE, CONSTRAINT `animalphotos_ibfk_1` FOREIGN KEY (`animal_id`) REFERENCES `animals` (`animal_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for animals -- ---------------------------- DROP TABLE IF EXISTS `animals`; CREATE TABLE `animals` ( `animal_id` int NOT NULL AUTO_INCREMENT COMMENT '动物唯一标识', `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '名称', `species` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT ' 种类', `gender` enum('雄','雌') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT ' 性别', `age` int NULL DEFAULT NULL COMMENT ' 年龄', `user_id` int NULL DEFAULT NULL COMMENT ' 关联饲养者/管理者(Users.user_id)', `zone` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '动物位置', PRIMARY KEY (`animal_id`) USING BTREE, INDEX `caretaker_id`(`user_id` ASC) USING BTREE, INDEX `species_id`(`species` ASC) USING BTREE, CONSTRAINT `animals_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for animaltraits -- ---------------------------- DROP TABLE IF EXISTS `animaltraits`; CREATE TABLE `animaltraits` ( `trait_id` int NOT NULL AUTO_INCREMENT COMMENT ' 特征ID', `animal_id` int NULL DEFAULT NULL COMMENT '动物ID(Animals)', `nature` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '性格 ', `favourite` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT ' 喜好描述', PRIMARY KEY (`trait_id`) USING BTREE, INDEX `animal_id`(`animal_id` ASC) USING BTREE, CONSTRAINT `animaltraits_ibfk_1` FOREIGN KEY (`animal_id`) REFERENCES `animals` (`animal_id`) ON DELETE RESTRICT ON UPDATE RESTRICT ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Table structure for users -- ---------------------------- DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `user_id` int NOT NULL AUTO_INCREMENT COMMENT ' 用户唯一标识', `username` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户名', `password` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '密码(加密)', `role` enum('游客','饲养者','管理员') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT ' 角色:游客/饲养者/管理员', `status` enum('在线','离线') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '用户状态(是否在线)', PRIMARY KEY (`user_id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; SET FOREIGN_KEY_CHECKS = 1; 这是我的实体类: // User 类 public class User { private int user_id; private String username; private String password; private String role; private String status; private List<Animals> animals; // 用户与动物是一对多关系 // getter 和 setter 方法 } // Animals 类 public class Animals { private int animal_id; private String name; private String gender; // 雄/雌 private Integer age; private String species; private String zone; private User user; // 动物与用户是一对多关系(反向关联) private List<AnimalPhoto> animalPhotos; // 动物与照片是一对多关系 // getter 和 setter 方法 } // AnimalPhoto 类 public class AnimalPhoto { private int photo_id; private Animals animal; // 照片与动物是一对多关系(反向关联) private String photo_url; // getter 和 setter 方法 } // AnimalTrait 类 public class AnimalTrait { private int trait_id; private Animals animal; // 特征与动物是一对一关系(反向关联) private String nature; // 性格 private String favourite; // 喜好描述 // getter 和 setter 方法 } 用户 (users) 与动物 (animals) 之间是一对多关系。 动物 (animals) 与照片 (animalphotos) 之间是一对多关系。 动物 (animals) 与特征 (animaltraits) 之间是一对一关系。 这是我登录注册代码: package com.cxy.Controller; import com.cxy.Pojo.User; import com.cxy.Service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpSession; import java.text.SimpleDateFormat; import java.util.Date; @Controller public class UserController { @Autowired private UserService userService; // 显示登录页面 @GetMapping("/login") public String loginPage(@RequestParam(value = "error", required = false) String error, Model model) { if (error != null) { model.addAttribute("error", true); } return "/login/login.jsp"; // 返回登录页面 } // 处理登录请求 @PostMapping("/login") public String login(@RequestParam String username, @RequestParam String password, HttpSession session, Model model) { User user = userService.login(username, password); if (user != null) { // 更新数据库中的在线状态 userService.updateUserStatus(user.getUserId(), "在线"); // 将用户信息存入 session session.setAttribute("user", user); session.setAttribute("username", user.getUsername()); // 存储用户名 session.setAttribute("role", user.getRole()); // 存储角色 session.setAttribute("status", "在线"); // 存储状态 session.setAttribute("loginTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 登录时间 return "redirect:/index.jsp"; // 登录成功,跳转到主页 } // 登录失败,返回登录页面并传递错误信息 model.addAttribute("loginError", "用户名或密码错误,请重新尝试。"); return "login/login.jsp"; } // 显示注册页面 @GetMapping("/register") public String registerPage() { return "/login/register.jsp"; // 返回注册页面 } // 处理注册请求 @PostMapping("/register") public String register(User user, Model model) { if (userService.register(user)) { return "/login/login.jsp"; // 注册成功,跳转到登录页面 } model.addAttribute("registerError", "用户名已存在"); // 用户名已存在 return "/login/register.jsp"; // 注册失败,返回注册页面 } // 处理退出登录 @GetMapping("/logout") public String logout(HttpSession session) { User user = (User) session.getAttribute("user"); if (user != null) { userService.updateUserStatus(user.getUserId(), "离线"); } session.invalidate(); // 清除session return "redirect:/login/login.jsp"; // 返回登录页面 } } 这是我实现登录注册的配置: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.cxy.Mapper.UserMapper"> <!-- 查询用户 --> <select id="findByUsername" resultType="com.cxy.Pojo.User"> SELECT * FROM users WHERE username = #{username} </select> <!-- 插入新用户 --> <insert id="insertUser" parameterType="com.cxy.Pojo.User"> INSERT INTO users (username, password, role) VALUES (#{username}, #{password}, #{role}) </insert> <!-- 更新在线状态 --> <update id="updateStatus"> UPDATE users SET status = #{status} WHERE user_id = #{user_id} </update> </mapper> application-dao.xml:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:jdbc.properties"/> <!-- 配置数据源 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.cxy.Mapper"/> </bean> </beans> application-service.xml:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 配置组件扫描 --> <context:component-scan base-package="com.cxy.Service"/> </beans> spring-mvc.xml:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="com.cxy.Controller"/> <mvc:annotation-driven/> <mvc:resources mapping="/css/**" location="/css/" /> </beans> web.xml:<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:application-*.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Spring DispatcherServlet --> <servlet> <servlet-name>Dispatcher</servlet-name> <servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- 配置 Spring DispatcherServlet 映射 --> <servlet-mapping> <servlet-name>Dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> index.jsp: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.Date" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!DOCTYPE html> <html> <head> <title>动物园数字档案管理系统</title> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/index.css"> </head> <body> <!-- 顶部导航栏 --> <header> <div class="logo"> <img src="<%= request.getContextPath() %>/images/zoo-logo.png" alt="Zoo Logo"> </div> <nav> <ul> <li><a href="${pageContext.request.contextPath}/index.jsp">首页</a></li> <li><a href="${pageContext.request.contextPath}/animal.jsp">动物信息</a></li> <li><a href="${pageContext.request.contextPath}/activities.jsp">活动预约</a></li> <li><a href="${pageContext.request.contextPath}/forum.jsp">用户交流</a></li> <% String username = (String) session.getAttribute("username"); String userRole = (String) session.getAttribute("role"); String userStatus = (String) session.getAttribute("status"); if ("饲养者".equals(userRole)) { out.println("<li><a href='" + request.getContextPath() + "/animal/list'>我的动物</a></li>"); } else if ("管理员".equals(userRole)) { out.println("<li><a href='" + request.getContextPath() + "/animal/list'>所有动物</a></li>"); } if (username == null) { out.println("<li><a href='" + request.getContextPath() + "/login/login.jsp'>登录/注册</a></li>"); } else { out.println("<li><a href='" + request.getContextPath() + "/logout'>退出登录</a></li>"); out.println("<li><span>登录时间: " + session.getAttribute("loginTime") + "</span></li>"); } %> </ul> </nav> </header> <!-- 主要内容 --> <div class="content"> <% if ("游客".equals(userRole)) { %> <div class="animal-search"> <h2>探索动物世界</h2> <input type="text" placeholder="搜索动物..."> <button onclick="window.location.href='${pageContext.request.contextPath}/activities.jsp'">立即预约活动</button> </div> <% } else if ("饲养者".equals(userRole)) { %> <div class="manage-animals"> <h2>饲养者面板</h2> <p>欢迎,<%= username %>!您当前状态:<%= userStatus %></p> </div> <% } else if ("管理员".equals(userRole)) { %> <div class="admin-panel"> <h2>管理员面板</h2> <p>欢迎,<%= username %>!您当前状态:<%= userStatus %></p> </div> <% } else { %> <div class="welcome-message"> <h2>欢迎来到动物园数字档案管理系统</h2> <p>请登录或注册以获取更多功能。</p> <button onclick="window.location.href='${pageContext.request.contextPath}/login/login.jsp'">登录/注册</button> </div> <% } %> </div> <!-- 底部信息栏 --> <footer> <div class="footer-content"> <p>©2023 动物园数字档案管理系统</p> <p>联系我们:info@zoodatabase.com</p> </div> </footer> </body> </html> add_animal.jsp: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!DOCTYPE html> <html> <head> <title>添加动物 - 动物园数字档案管理系统</title> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/animal_form.css"> </head> <body> <jsp:include page="/header.jsp"/> <div class="container"> <h1>添加新动物</h1> <form action="${pageContext.request.contextPath}/animal/add" method="post" enctype="multipart/form-data"> <div class="form-group"> <label for="name">动物名称:</label> <input type="text" id="name" name="name" required> </div> <div class="form-group"> <label for="species">种类:</label> <input type="text" id="species" name="species" required> </div> <div class="form-group"> <label for="gender">性别:</label> <select id="gender" name="gender" required> <option value="">请选择</option> <option value="雄">雄</option> <option value="雌">雌</option> </select> </div> <div class="form-group"> <label for="age">年龄:</label> <input type="number" id="age" name="age" min="0" required> </div> <div class="form-group"> <label for="zone">位置:</label> <input type="text" id="zone" name="zone" required> </div> <div class="form-group"> <label for="photo_url">上传照片:</label> <input type="file" id="photo_url" name="photo_url" multiple> </div> <div class="form-group"> <label for="nature">性格:</label> <input type="text" id="nature" name="nature" required> </div> <div class="form-group"> <label for="favourite">喜好描述:</label> <textarea id="favourite" name="favourite"></textarea> </div> <div class="form-actions"> <button type="submit" class="btn btn-primary">添加动物</button> <a href="${pageContext.request.contextPath}/animal/list" class="btn btn-secondary">取消</a> </div> </form> </div> 注意:查询查的是动物完整的信息(包括图片),添加也要添加动物完整的信息,可以对数据库插入动物图片。这需要对表进行关联。 请根据我的配置和我给出的添加动物页面add_aniaml.jsp,用javaee的ssm整合框架实现饲养者和管理者对动物的增删改查,,以及写出对应的jsp页面:在/animal/目录内,并修改index页面。包括(controller接口,mapper接口,service,serviceimpl和Mapper新配置)。其中饲养者登录时:显示我的动物导航栏,点击进入页面只能对自己添加的动物进行修改数据和删除,也可以在该页面添加新的动物。而管理者登录时:显示所有动物导航栏,点击进入页面,可以对全部动物信息增删改。饲养者和管理者可以对动物所有信息进行写入。
05-29
(一)项目构建 使用 Maven 构建项目,在pom.xml中引入 Spring MVC 相关依赖,如spring - webmvc,配置 Servlet、JSP 等相关依赖,确保项目具备 Spring MVC 运行环境 。示例关键依赖配置: <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring - webmvc</artifactId> <version>5.3.18</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet - api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>javax.servlet.jsp - api</artifactId> <version>2.3.3</version> <scope>provided</scope> </dependency> <!-- 其他如JSTL等依赖按需添加 --> </dependencies> (二)Spring MVC 配置 DispatcherServlet 配置:在 Web.xml(或 Servlet 3.0 + 环境下用 Java 配置)中配置 DispatcherServlet,指定 Spring MVC 配置文件位置,使其能拦截处理请求 。示例 Web.xml 配置: <servlet> <servlet - name>springmvc</servlet - name> <servlet - class>org.springframework.web.servlet.DispatcherServlet</servlet - class> <init - param> <param - name>contextConfigLocation</param - name> <param - value>classpath:springmvc - servlet.xml</param - value> </init - param> <load - on - startup>1</load - on - startup> </servlet> <servlet - mapping> <servlet - name>springmvc</servlet - name> <url - pattern>/</url - pattern> </servlet - mapping> Spring MVC 配置文件(springmvc - servlet.xml):开启组件扫描(扫描控制器等组件)、视图解析器(配置前缀后缀,解析 JSP 视图)、开启注解驱动等 。示例: <context:component - scan base - package="com.example.controller"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB - INF/views/"/> <property name="suffix" value=".jsp"/> </bean> <mvc:annotation - driven/> 三)功能模块实现 1. 用户登录验证 o 控制器(Controller):创建LoginController,编写方法处理/login请求(对应login.jsp表单提交),接收用户名、密码参数(可通过@RequestParam注解),进行简单验证(如硬编码用户名 “admin”、密码 “123” 模拟,实际可连数据库查询),验证成功用return "redirect:/main";重定向到主页控制器方法,失败则带错误信息(通过model.addAttribute)返回login视图(即login.jsp )。示例代码: package com.example.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class LoginController { @RequestMapping("/login") public String login(@RequestParam("username") String username, @RequestParam("password") String password, Model model) { if ("admin".equals(username) && "123".equals(password)) { return "redirect:/main"; } else { model.addAttribute("error", "用户名或密码错误"); return "login"; } } 2. 登录页面(login.jsp):使用 Spring 表单标签库(需引入相关标签库)或普通 HTML 表单,提交到/login,显示错误信息(通过 EL 表达式${error} )。示例关键代码: <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <html> <body> <form:form action="/login" method="post"> 用户名:<form:input path="username"/><br> 密码:<form:password path="password"/><br> <input type="submit" value="登录"> </form:form> <c:if test="${not empty error}"> <p style="color:red">${error}</p> </c:if> </body> </html> 3. 访问控制(拦截器实现) o 创建拦截器类:实现HandlerInterceptor接口,在preHandle方法中检查会话是否有用户登录标识(如session.getAttribute("user") ,假设登录成功时在会话存user对象),无则redirect到/login并返回false拦截,有则返回true放行 。示例: package com.example.interceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.HandlerInterceptor; public class LoginInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Object user = request.getSession().getAttribute("user"); if (user == null) { response.sendRedirect(request.getContextPath() + "/login"); return false; } return true; } } 4. 配置拦截器:在 Spring MVC 配置文件(springmvc - servlet.xml)中注册拦截器,指定拦截路径(如/main )。示例: <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/main"/> <bean class="com.example.interceptor.LoginInterceptor"/> </mvc:interceptor> </mvc:interceptors> 5. 会话管理(登出功能) o 控制器方法:在MainController中编写处理登出的方法,调用session.invalidate()销毁会话,然后redirect到登录页 。示例: package com.example.controller; import javax.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class MainController { @RequestMapping("/main") public String main() { return "main"; } @RequestMapping("/logout") public String logout(HttpSession session) { session.invalidate(); return "redirect:/login"; } } 6. 主页(main.jsp):添加 “退出” 链接, href 指向/logout 。示例: <html> <body> <h1>欢迎访问主页</h1> <a href="${pageContext.request.contextPath}/logout">退出</a> </body> </html>
06-05
contactList.jsp:<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>${isBlacklist ? '黑名单' : '联系人列表'}</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet"> <style> :root { --primary-color: #4361ee; --secondary-color: #3f37c9; --success-color: #4cc9f0; --danger-color: #f72585; --warning-color: #f8961e; --light-color: #f8f9fa; --dark-color: #212529; } body { background-color: #f5f7fa; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } .container { max-width: 1400px; padding: 20px; } .header-section { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: white; border-radius: 15px; padding: 2rem; margin-bottom: 2rem; box-shadow: 0 10px 20px rgba(67, 97, 238, 0.15); } .page-title { font-weight: 700; margin: 0; display: flex; align-items: center; } .page-title i { font-size: 2rem; margin-right: 1rem; } .action-buttons .btn { border-radius: 50px; padding: 0.5rem 1.5rem; font-weight: 500; margin-left: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; } .action-buttons .btn:hover { transform: translateY(-2px); box-shadow: 0 7px 14px rgba(0, 0, 0, 0.15); } .nav-tabs { border-bottom: none; margin: 1.5rem 0; } .nav-tabs .nav-link { border: none; color: #6c757d; font-weight: 500; padding: 0.75rem 1.5rem; border-radius: 50px; margin-right: 0.5rem; transition: all 0.3s ease; } .nav-tabs .nav-link.active { background-color: var(--primary-color); color: white; box-shadow: 0 4px 6px rgba(67, 97, 238, 0.3); } .nav-tabs .nav-link:not(.active):hover { color: var(--primary-color); background-color: rgba(67, 97, 238, 0.1); } .search-box { background: white; border-radius: 50px; padding: 0.5rem; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); } .search-box input { border: none; border-radius: 50px 0 0 50px; padding: 0.75rem 1.5rem; } .search-box input:focus { box-shadow: none; } .search-box button { border-radius: 0 50px 50px 0; background-color: var(--primary-color); color: white; border: none; padding: 0.75rem 1.5rem; transition: all 0.3s ease; } .search-box button:hover { background-color: var(--secondary-color); } .contact-card { background: white; border-radius: 15px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05); transition: all 0.3s ease; margin-bottom: 1.5rem; overflow: hidden; } .contact-card:hover { transform: translateY(-5px); box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1); } .contact-avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid white; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); } .contact-info { padding: 1.5rem; } .contact-name { font-weight: 600; color: var(--dark-color); margin-bottom: 0.5rem; } .contact-phone { color: #6c757d; font-size: 0.9rem; } .status-badge { font-size: 0.8rem; padding: 0.35rem 0.75rem; border-radius: 50px; font-weight: 500; } .action-btn { min-width: 100px; border-radius: 50px; font-size: 0.85rem; font-weight: 600; padding: 0.5rem 1rem; margin: 0.25rem; transition: all 0.3s ease; } .action-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1); } .pagination { margin-top: 3rem; justify-content: center; } .page-item .page-link { border-radius: 50px !important; margin: 0 0.25rem; border: none; color: var(--dark-color); font-weight: 500; min-width: 40px; text-align: center; } .page-item.active .page-link { background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)); color: white; box-shadow: 0 4px 6px rgba(67, 97, 238, 0.3); } .no-contacts { text-align: center; padding: 3rem; color: #6c757d; } .no-contacts i { font-size: 3rem; color: #dee2e6; margin-bottom: 1rem; } /* 天气预报样式 */ .weather-widget { background: linear-gradient(135deg, #1e3c72, #2a5298); color: white; border-radius: 15px; padding: 2rem; margin-bottom: 2rem; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15); position: relative; overflow: hidden; } .weather-widget::before { content: ""; position: absolute; top: -50%; right: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%); z-index: 0; } .weather-content { position: relative; z-index: 1; } .weather-title { font-weight: 700; margin: 0; display: flex; align-items: center; font-size: 1.5rem; } .weather-title i { font-size: 1.8rem; margin-right: 1rem; } .weather-details { display: flex; align-items: center; justify-content: space-between; margin-top: 1.5rem; } .weather-info { flex: 1; } .weather-city { font-size: 1.8rem; font-weight: 600; margin-bottom: 0.5rem; } .weather-desc { font-size: 1.2rem; opacity: 0.9; margin-bottom: 0.5rem; text-transform: capitalize; } .weather-temp { font-size: 3rem; font-weight: 700; margin: 0; line-height: 1; } .weather-icon-container { width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; } .weather-icon { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3)); } .weather-extra { display: flex; justify-content: space-between; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.2); } .weather-extra-item { text-align: center; flex: 1; } .weather-extra-label { font-size: 0.9rem; opacity: 0.8; margin-bottom: 0.3rem; } .weather-extra-value { font-size: 1.2rem; font-weight: 600; } /* 天气动画 */ @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } .weather-animate { animation: fadeIn 0.5s ease-out forwards; } /* 移动端特定样式 */ @media (max-width: 768px) { .header-section { padding: 1.5rem; } .action-buttons { margin-top: 1rem; } .contact-avatar { width: 60px; height: 60px; } .action-btn { min-width: auto; padding: 0.4rem 0.8rem; font-size: 0.8rem; } .search-box input, .search-box button { padding: 0.5rem 1rem; } .nav-tabs .nav-link { padding: 0.5rem 1rem; margin-right: 0.25rem; } .weather-widget { padding: 1.5rem; } .weather-temp { font-size: 2rem; } .weather-city { font-size: 1.2rem; } } /* 触摸友好元素 */ .btn, .form-control, .nav-link, .page-link { touch-action: manipulation; } </style> </head> <body> <div class="container"> <div class="header-section"> <div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center"> <h1 class="page-title"> <i class="bi bi-people-fill"></i> ${isBlacklist ? '黑名单管理' : '联系人中心'} </h1> <div class="action-buttons mt-3 mt-md-0"> <a href="${pageContext.request.contextPath}/contact?action=add" class="btn btn-light"> <i class="bi bi-person-plus"></i> 新增联系人 </a> <a href="${pageContext.request.contextPath}/matter" class="btn btn-outline-light"> <i class="bi bi-calendar2-event"></i> 查看事项 </a> </div> </div> </div> <!-- 天气预报区域 --> <div class="weather-widget"> <div class="weather-content"> <h2 class="weather-title"> <i class="bi bi-geo-alt"></i> 实时天气 </h2> <div class="weather-details"> <div class="weather-info"> <div class="weather-city" id="weatherCity">唐山</div> <div class="weather-desc" id="weatherDesc">--</div> <div class="weather-temp" id="weatherTemp">--°C</div> </div> <div class="weather-icon-container"> <img id="weatherIcon" class="weather-icon" src="https://openweathermap.org/img/wn/${data.weather.icon}@2x.png" alt="天气图标"> </div> </div> </div> </div> <div class="weather-extra"> <div class="weather-extra-item"> <div class="weather-extra-label">湿度</div> <div class="weather-extra-value" id="weatherHumidity">--%</div> </div> <div class="weather-extra-item"> <div class="weather-extra-label">风速</div> <div class="weather-extra-value" id="weatherWind">-- m/s</div> </div> <div class="weather-extra-item"> <div class="weather-extra-label">气压</div> <div class="weather-extra-value" id="weatherPressure">-- hPa</div> </div> </div> <ul class="nav nav-tabs"> <li class="nav-item"> <a class="nav-link ${not isBlacklist ? 'active' : ''}" href="${pageContext.request.contextPath}/contact">正常联系人</a> </li> <li class="nav-item"> <a class="nav-link ${isBlacklist ? 'active' : ''}" href="${pageContext.request.contextPath}/contact?action=blacklist">黑名单</a> </li> </ul> <!-- 筛选区域 --> <div class="filter-section"> <h5 class="filter-title">筛选条件</h5> <form class="row g-3" method="get" action="${pageContext.request.contextPath}/contact"> <input type="hidden" name="action" value="${isBlacklist ? 'blacklist' : ''}"> <div class="col-md-6"> <div class="input-group"> <input type="text" class="form-control" name="search" placeholder="搜索姓名/电话" value="${param.search}" aria-label="Search"> <button class="btn btn-primary" type="submit"> <i class="bi bi-search"></i> 搜索了一个 </button> </div> </div> <div class="col-md-4"> <select class="form-select" name="gender" onchange="this.form.submit()"> <option value="">所有性别</option> <option value="男" ${param.gender == '男' ? 'selected' : ''}>男</option> <option value="女" ${param.gender == '女' ? 'selected' : ''}>女</option> </select> </div> <div class="col-md-2"> <a href="${pageContext.request.contextPath}/contact${isBlacklist ? '?action=blacklist' : ''}" class="btn btn-outline-secondary w-100"> <i class="bi bi-arrow-counterclockwise"></i> 重置 </a> </div> </form> </div> <c:if test="${empty contacts}"> <div class="card contact-card"> <div class="no-contacts"> <i class="bi bi-people"></i> <h4>暂无联系人数据</h4> <p>点击"新增联系人"按钮添加您的第一个联系人</p> </div> </div> </c:if> <div class="row"> <c:forEach var="contact" items="${contacts}"> <div class="col-md-6 col-lg-4"> <div class="card contact-card"> <div class="contact-info"> <div class="d-flex align-items-center"> <img src="${pageContext.request.contextPath}/upload/${DBUtil.getContactPic(contact.ctId)}" class="contact-avatar me-3" onerror="this.onerror=null; this.src='${pageContext.request.contextPath}/images/default-avatar.png'"> <div> <h5 class="contact-name mb-1"> ${contact.ctName} <c:if test="${contact.ctDelete == 1}"> <span class="badge bg-danger ms-2">已屏蔽</span> </c:if> </h5> <p class="contact-phone mb-1"> <i class="bi bi-telephone"></i> ${contact.ctPhone} </p> <span class="status-badge bg-${isBlacklist ? 'danger' : 'success'}"> ${isBlacklist ? '黑名单' : '正常'} </span> </div> </div> <div class="d-flex flex-wrap justify-content-between mt-3"> <a href="${pageContext.request.contextPath}/contact?action=detail&ctId=${contact.ctId}" class="btn btn-primary action-btn"> <i class="bi bi-eye"></i> 详情 </a> <a href="${pageContext.request.contextPath}/matter?ctId=${contact.ctId}" class="btn btn-warning action-btn"> <i class="bi bi-list-check"></i> 事项 </a> <c:choose> <c:when test="${isBlacklist}"> <a href="${pageContext.request.contextPath}/contact?action=blacklist&type=remove&ctId=${contact.ctId}" class="btn btn-success action-btn" onclick="return confirm('确定要恢复此联系人吗?')"> <i class="bi bi-arrow-counterclockwise"></i> 恢复 </a> </c:when> <c:otherwise> <c:if test="${contact.ctDelete == 0}"> <a href="${pageContext.request.contextPath}/contact?action=blacklist&type=add&ctId=${contact.ctId}" class="btn btn-danger action-btn" onclick="return confirm('确定要加入黑名单吗?')"> <i class="bi bi-ban"></i> 屏蔽 </a> </c:if> </c:otherwise> </c:choose> </div> </div> </div> </div> </c:forEach> </div> <c:if test="${not empty contacts}"> <nav aria-label="Page navigation"> <ul class="pagination"> <c:if test="${currentPage > 1}"> <li class="page-item"> <a class="page-link" href="${pageContext.request.contextPath}/contact?action=${isBlacklist ? 'blacklist' : ''}&page=${currentPage - 1}&search=${param.search}"> <i class="bi bi-chevron-left"></i> </a> </li> </c:if> <c:forEach begin="1" end="${totalPages}" var="i"> <li class="page-item ${i == currentPage ? 'active' : ''}"> <a class="page-link" href="${pageContext.request.contextPath}/contact?action=${isBlacklist ? 'blacklist' : ''}&page=${i}&search=${param.search}">${i}</a> </li> </c:forEach> <c:if test="${currentPage < totalPages}"> <li class="page-item"> <a class="page-link" href="${pageContext.request.contextPath}/contact?action=${isBlacklist ? 'blacklist' : ''}&page=${currentPage + 1}&search=${param.search}"> <i class="bi bi-chevron-right"></i> </a> </li> </c:if> </ul> </nav> </c:if> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script> // 获取天气数据 function getWeather() { const apiKey = "d9bd1b0c215b38f1ceba3a8b06818789"; // OpenWeatherMap API密钥 const city = "Tangshan"; // 唐山的英文名 // 获取唐山天气 fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=${apiKey}&units=metric&lang=zh_cn`) .then(response => { if (!response.ok) { throw new Error("网络响应错误:" + response.statusText); } return response.json(); }) .then(data => { updateWeatherUI(data); }) .catch(error => { console.error('获取天气数据失败:', error); showWeatherError(); }); } // 更新天气UI function updateWeatherUI(data) { document.getElementById('weatherTemp').textContent = `${Math.round(data.main.temp)}°C`; document.getElementById('weatherDesc').textContent = data.weather[0]?.description || "--"; document.getElementById('weatherIcon').src = `https://openweathermap.org/img/wn/${data.weather.icon}@2x.png`; document.getElementById('weatherHumidity').textContent = `${data.main.humidity}%`; document.getElementById('weatherWind').textContent = `${data.wind.speed} m/s`; document.getElementById('weatherPressure').textContent = `${data.main.pressure} hPa`; } // 显示天气错误 function showWeatherError() { document.getElementById('weatherCity').textContent = "天气数据获取失败"; document.getElementById('weatherDesc').textContent = "请检查网络连接"; document.getElementById('weatherTemp').textContent = "--°C"; document.getElementById('weatherHumidity').textContent = "--%"; document.getElementById('weatherWind').textContent = "-- m/s"; document.getElementById('weatherPressure').textContent = "-- hPa"; } // 页面加载完成后获取天气数据 document.addEventListener('DOMContentLoaded', getWeather); </script> </body> </html>控制台日志:D:\apache-tomcat-8.5.99\bin\catalina.bat run [2025-06-10 09:39:00,390] Artifact firstweb2:war: Waiting for server connection to start artifact deployment... Using CATALINA_BASE: "C:\Users\DELL\AppData\Local\JetBrains\IntelliJIdea2022.2\tomcat\673dafd6-7580-4107-962c-bab19e459aa1" Using CATALINA_HOME: "D:\apache-tomcat-8.5.99" Using CATALINA_TMPDIR: "D:\apache-tomcat-8.5.99\temp" Using JRE_HOME: "D:\java" Using CLASSPATH: "D:\apache-tomcat-8.5.99\bin\bootstrap.jar;D:\apache-tomcat-8.5.99\bin\tomcat-juli.jar" Using CATALINA_OPTS: "" NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Server.服务器版本: Apache Tomcat/8.5.99 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 服务器构建: Feb 14 2024 22:52:13 UTC 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 服务器版本号: 8.5.99.0 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 操作系统名称: Windows 11 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: OS.版本: 10.0 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 架构: amd64 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Java 环境变量: D:\java 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: Java虚拟机版本: 18.0.2.1+1-1 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: JVM.供应商: Oracle Corporation 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_BASE: C:\Users\DELL\AppData\Local\JetBrains\IntelliJIdea2022.2\tomcat\673dafd6-7580-4107-962c-bab19e459aa1 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: CATALINA_HOME: D:\apache-tomcat-8.5.99 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: --add-opens=java.base/java.lang=ALL-UNNAMED 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: --add-opens=java.base/java.io=ALL-UNNAMED 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: --add-opens=java.base/java.util=ALL-UNNAMED 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Djava.util.logging.config.file=C:\Users\DELL\AppData\Local\JetBrains\IntelliJIdea2022.2\tomcat\673dafd6-7580-4107-962c-bab19e459aa1\conf\logging.properties 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dcom.sun.management.jmxremote= 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dcom.sun.management.jmxremote.port=1099 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dcom.sun.management.jmxremote.ssl=false 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dcom.sun.management.jmxremote.password.file=C:\Users\DELL\AppData\Local\JetBrains\IntelliJIdea2022.2\tomcat\673dafd6-7580-4107-962c-bab19e459aa1\jmxremote.password 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dcom.sun.management.jmxremote.access.file=C:\Users\DELL\AppData\Local\JetBrains\IntelliJIdea2022.2\tomcat\673dafd6-7580-4107-962c-bab19e459aa1\jmxremote.access 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Djava.rmi.server.hostname=127.0.0.1 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Djdk.tls.ephemeralDHKeySize=2048 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dignore.endorsed.dirs= 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dcatalina.base=C:\Users\DELL\AppData\Local\JetBrains\IntelliJIdea2022.2\tomcat\673dafd6-7580-4107-962c-bab19e459aa1 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Dcatalina.home=D:\apache-tomcat-8.5.99 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.VersionLoggerListener log 信息: 命令行参数: -Djava.io.tmpdir=D:\apache-tomcat-8.5.99\temp 6月 10, 2025 9:39:01 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: 使用APR版本[1.7.4]加载了基于APR的Apache Tomcat本机库[1.2.39]。 6月 10, 2025 9:39:01 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: APR功能:IPv6[true]、sendfile[true]、accept filters[false]、random[true]、UDS [{4}]。 6月 10, 2025 9:39:01 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent 信息: APR/OpenSSL配置:useAprConnector[false],useOpenSSL[true] 6月 10, 2025 9:39:01 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL成功初始化 [OpenSSL 3.0.11 19 Sep 2023] 6月 10, 2025 9:39:01 下午 org.apache.coyote.AbstractProtocol init 信息: 初始化协议处理器 ["http-nio-8080"] 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 370 ms 6月 10, 2025 9:39:01 下午 org.apache.catalina.core.StandardService startInternal 信息: 正在启动服务[Catalina] 6月 10, 2025 9:39:01 下午 org.apache.catalina.core.StandardEngine startInternal 信息: 正在启动 Servlet 引擎:[Apache Tomcat/8.5.99] 6月 10, 2025 9:39:01 下午 org.apache.coyote.AbstractProtocol start 信息: 开始协议处理句柄["http-nio-8080"] 6月 10, 2025 9:39:01 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 82 ms Connected to server [2025-06-10 09:39:01,626] Artifact firstweb2:war: Artifact is being deployed, please wait... 6月 10, 2025 9:39:02 下午 org.apache.jasper.servlet.TldScanner scanJars 信息: 至少有一个JAR被扫描用于TLD但尚未包含TLD。 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。 ־ ʼ === ݿ === û (user_message) ϵ ˱ (contact_message) ϵ ͼƬ (contact_picture_message) ϵ (contact_matter_message) === === ־ ʼ === ݿ === û (user_message) ϵ ˱ (contact_message) ϵ ͼƬ (contact_picture_message) ϵ (contact_matter_message) === === [2025-06-10 09:39:02,537] Artifact firstweb2:war: Artifact is deployed successfully [2025-06-10 09:39:02,537] Artifact firstweb2:war: Deploy took 911 milliseconds === Ϣ === URL: http://localhost:8080/firstweb2_war/ 󷽷 : GET : null û ỰID: === Ϣ === URL: http://localhost:8080/firstweb2_war/ 󷽷 : GET : null û ỰID: === Ӧ Ϣ === Ӧ״̬: 200 ʱ : 2ms === === === Ӧ Ϣ === Ӧ״̬: 200 ʱ : 3ms === === === Ϣ === URL: http://localhost:8080/firstweb2_war/login 󷽷 : POST : null û ỰID: === Ϣ === URL: http://localhost:8080/firstweb2_war/login 󷽷 : POST : null û ỰID: === Ӧ Ϣ === Ӧ״̬: 302 ʱ : 29ms === === === Ӧ Ϣ === Ӧ״̬: 302 ʱ : 29ms === === === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : null û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : null û ỰID: EDB570CA9B045C3BD0946687C2639008 6月 10, 2025 9:39:11 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: 把web 应用程序部署到目录 [D:\apache-tomcat-8.5.99\webapps\manager] 6月 10, 2025 9:39:11 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Web应用程序目录[D:\apache-tomcat-8.5.99\webapps\manager]的部署已在[153]毫秒内完成 === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : action=detail&ctId=0000000002 û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : action=detail&ctId=0000000002 û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ӧ Ϣ === Ӧ״̬: 200 ʱ : 180ms === === === Ӧ Ϣ === Ӧ״̬: 200 ʱ : 180ms === === === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : POST : action=update&ctId=0000000002 û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : POST : action=update&ctId=0000000002 û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ӧ Ϣ === Ӧ״̬: 302 ʱ : 93ms === === === Ӧ Ϣ === Ӧ״̬: 302 ʱ : 93ms === === === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : action=detail&ctId=0000000002 û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : action=detail&ctId=0000000002 û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ӧ Ϣ === Ӧ״̬: 200 ʱ : 31ms === === === Ӧ Ϣ === Ӧ״̬: 200 ʱ : 32ms === === === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : null û ỰID: EDB570CA9B045C3BD0946687C2639008 === Ϣ === URL: http://localhost:8080/firstweb2_war/contact 󷽷 : GET : null û ỰID: EDB570CA9B045C3BD0946687C2639008 还是无法查看天气情况,无法更新,请基于我的代码给出具体的解决措施和代码,代码要完完整整的,要全部的
06-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值