登录业务逻辑
登录业务逻辑
修改 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">
<!-- 不加载无用Jar包 -->
<absolute-ordering/>
<!--核心过滤器-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--Spring的核心监听器-->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!--
加载Spring的配置文件的路径的
默认加载的/WEB-INF/applicationContext.xml
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 欢迎页,也就是启动项目默认系统访问的页面 -->
<welcome-file-list>
<welcome-file>mgr_login.jsp</welcome-file>
</welcome-file-list>
</web-app>
修改 web/mgr_login.jsp
<form action="${pageContext.request.contextPath}/loginAction_login.action" id="login_form">
<div class="login">博客后台管理系统</div>
<div class="username-text">用户名:</div>
<div class="password-text">密码:</div>
<div class="username-field">
<input type="text" name="username" value="BNTang"/>
</div>
<div class="password-field">
<input type="password" name="password" value="1234"/>
</div>
<input type="checkbox" name="remember-me" id="remember-me"/>
<label for="remember-me">记住用户名</label>
<div class="forgot-usr-pwd"></div>
<input type="submit" name="submit" value="登录" style="font-size: 16px;margin-top:-1px;"/>
</form>
在 src/top/it6666/web 中添加 LoginAction
package top.it6666.web;
import com.opensymphony.xwork2.ActionSupport;
/**
* @author tangyihao
* @version V1.1.1
* @program it6666-Blog
* @date Created in 2020/9/3 8:53
* @description 登陆Action
**/
public class LoginAction extends ActionSupport {
public String login() {
System.out.println("login来了");
return null;
}
}
修改 struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="struts" extends="struts-default">
<action name="loginAction_*" class="top.it6666.web.LoginAction" method="{1}">
<allowed-methods>login</allowed-methods>
</action>
</package>
</struts>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· winform 绘制太阳,地球,月球 运作规律
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具