SSH与SSM简介
SSM:Spring+SpringMVC+Mybatis
SSH:Struts2+Hibernate+Spring
Struts2:是侧重于控制层的框架
Hibernate:是一个ORM(Object Relation Mapping)的产品,专职于做DAO层
Spring:是一个项目的大管家或者是大容器。它负责各个层次的融合

为什么要用框架来开发项目?
1.简化开发流程
2.标准化开发流程
3.增强项目的扩展性和维护性

Struts2的开发流程:
1.新建web项目,加入struts2的核心jar包

2.在项目中的web.xml中加入struts2的核心过滤器

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>struts2_06</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>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

3.在src目录下创建一个struts.xml的配置文件

4.在src目录下新建Action普通类,在类中写一个public String execute() 返回一个字符串

package com.action;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport{
public String execute(){
System.out.println("我的struts2第一个action");
return "success";
}
}

5.在struts.xml中完成Action的注册配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="my" namespace="/" extends="struts-default">
<action name="login" class="com.action.LoginAction">
<result name="success">/jsp/success.jsp</result>
</action>
</package>
</struts>

注意:name="login"是指action的访问路径
    <result name="success">/jsp/success.jsp</result>:是返回后的跳转结果

6.login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="login">
用户名:<input name="username"><br>
密码:<input type="password" name="pwd"><br>
<input type="submit" value="提交">
</form>
</body>
</html>

  点击提交即可跳转至success.jsp页面

一 Struts2 开发流程的更多相关文章

  1. struts2开发流程及配置,域对象对数据存储的3种方式

    一.开发流程 1)引入 jar 包,其中必须引入的有(我是用的struts是2.3.32) commons-fileupload-1.3.2.jar     |文件上传下载commons-io-2.2 ...

  2. 1.struts2开发流程

    1下载struts包,下载地址为:http://archive.apache.org/dist/struts/library/   2.解压后将lib下的这几个jar包放到自己写的web项目中 放到这 ...

  3. Struts2学习笔记--Struts例子及开发流程

    参考资料:http://blog.csdn.net/hntyzgn2010/article/details/5547753 http://chenlh.iteye.com/blog/464341 入门 ...

  4. Struts2应用的开发流程

    Struts2的开发流程 为了能够在eclipse中使用Struts2在进行开发时,需要根据需要导入一些有关的jar包: 在官网下载相关的压缩包,这里下载了两个:struts-2.3.30-all.z ...

  5. struts2 之 【struts2简介,struts2开发步骤,struts2详细配置,struts2执行流程】

    入门框架学习避免不了的问题: 1. 什么是框架? 简单的说,框架就是模板,模子,模型.就是一个可重用的半成品. 2. 如何学习框架? 学习框架其实就是学习规则,使用框架就是遵循框架的规则,框架是可变的 ...

  6. struts2系列(一):struts2入门(struts2的产生、struts2的工作流程、搭建struts2开发环境)

    一. struts2的产生 struts1的缺点:                         1. ActionForm过多,而且这个ActionForm在很大程度上又和VO(POJO)重复  ...

  7. Struts2学习第一天——struts2基本流程与配置

    struts2框架 什么是框架,框架有什么用? 框架 是 实现部分功能的代码 (半成品),使用框架简化企业级软件开发 ,提高开发效率. 学习框架 ,清楚的知道框架能做什么? 还有哪些工作需要自己编码实 ...

  8. Struts2开发模式漏洞

    当Struts2中的devMode模式设置为true时,存在严重远程代码执行漏洞.如果WEB服务以最高权限运行时,可远程执行任意命令,包括远程控制服务器. 如果为受影响的版本,建议修改配置文件stru ...

  9. springmvc与struts2执行流程比较

    之前写过一篇struts2的执行流程的文章了,这里对struts2的流程就不做过多的分析,这篇文章主要分析spring-mvc的执行流程以 及struts2与spring-mvc的差别. 1.stru ...

随机推荐

  1. 第2章 术语 - Identity Server 4 中文文档(v1.0.0)

    规范.文档和对象模型等都使用特定的术语来表述. 2.1 IdentityServer IdentityServer是OpenID Connect提供程序 - 它实现OpenID Connect和OAu ...

  2. SQL Server表名为添加中括号[]执行出错

    执行SQL语句: Update Check Set EOBTypeID=102 where E0BID='123344' 结果竟然报错,给表名添加中括号,写成这样: Update [Check] Se ...

  3. 结合JDK源码看设计模式——享元模式

    前言 在说享元模式之前,你一定见到过这样的面试题 public class Test { public static void main(String[] args) { Integer a=Inte ...

  4. mybatis基础(上)

    框架图 SqlSessionFactoryBuilder 通过SqlSessionFactoryBuilder创建会话工厂SqlSessionFactory 将SqlSessionFactoryBui ...

  5. [转载] spring aop 环绕通知around和其他通知的区别

    前言: spring 的环绕通知和前置通知,后置通知有着很大的区别,主要有两个重要的区别: 1) 目标方法的调用由环绕通知决定,即你可以决定是否调用目标方法,而前置和后置通知   是不能决定的,他们只 ...

  6. 前端入门11-JavaScript语法之数组

    声明 本系列文章内容全部梳理自以下几个来源: <JavaScript权威指南> MDN web docs Github:smyhvae/web Github:goddyZhao/Trans ...

  7. vue 中promise 异步请求数据

    export function getTypes(type) { return listDictItems({ code: type }).then((res) => { if (res.cod ...

  8. web前端自动化测试/爬虫利器puppeteer介绍

    web前端自动化测试/爬虫利器puppeteer介绍 Intro Chrome59(linux.macos). Chrome60(windows)之后,Chrome自带headless(无界面)模式很 ...

  9. 前后端分离djangorestframework—— 接入第三方的验证码平台

    关于验证码部分,在我这篇文章里说的挺详细的了:Python高级应用(3)—— 为你的项目添加验证码 这里还是再给一个前后端分离的实例,因为极验官网给的是用session作为验证的,而我们做前后端分离的 ...

  10. Cs231n-assignment 1作业笔记

    KNN assignment1 KNN讲解参见: https://blog.csdn.net/u014485485/article/details/79433514?utm_source=blogxg ...