struts访问流程
来源:互联网 发布:淘宝介入的原则 编辑:程序博客网 时间:2024/06/08 14:02
1.web.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
.会通过上面<welcome-file-list> <welcome-file>login.jsp</welcome-file></welcome-file-list>先访问登录页面
2.login.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html><head>
<title>用户登录界面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="login.action" method="post">
用户名:<input type="text" name="userName"/><br/>
密码:<input type="password" name="password"/><br/>
<input type="submit" value="提交"/>
</form>
</body>
</html>
通过提交表单中的login.action,去找struts.xml中的配置
3.struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="test" extends="struts-default">
<action name="login" class="com.suo.Login" method="execute">
<result name="success">/WEB-INF/jsp/success.jsp</result>
<result name="fail">/WEB-INF/jsp/fail.jsp</result>
</action>
</package>
</struts>
找到匹配的action名称login找到,这个action的类的位置,和执行方法,根据方法执行结果进行跳转
- struts访问流程
- Struts流程
- struts流程
- struts流程
- struts流程
- struts流程
- struts 流程
- Struts流程
- Struts流程
- struts流程
- 访问流程
- struts的流程
- struts的流程
- struts的流程
- struts的流程
- 简述Struts流程
- Struts工作流程
- Struts开发工作流程
- iOS 面试中遇到的部分问题及简单答案(1)->(陆续更新)
- Apache Ignite之集群应用测试
- XML文件转换成字符串互相转换操作
- 背景色根据状态更改颜色 android:backgroup
- java抽象类
- struts访问流程
- 面试Java基础之ArrayList、LinkedList、Vector比较
- JDBC---DAO经典模式
- 单例模式
- Java序列化之transient
- 线上应用故障排查之一:高CPU占用
- jira scriptrunner的并行审批遇到的一点问题
- 推荐阅读书籍《亿级流量网站架构核心技术》目录一览
- 启动APK的默认Activity