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. Ubuntu安装谷歌浏览器

    首选方法: sudo wget http://www.linuxidc.com/files/repo/google-chrome.list -P /etc/apt/sources.list.d/ wg ...

  2. 查看服务器运行多少个ASP.NET Core程序

    有时候,我们会想知道某台机器上面跑了什么程序. 当程序部署到IIS上面的时候,我们只需要打开IIS一看,就知道有多少个站点在运行了. 当我们在CentOS上面部署的时候,就没那么的直观了. 当然对于熟 ...

  3. javascript基础修炼(5)—Event Loop(Node.js)

    开发者的javascript造诣取决于对[动态]和[异步]这两个词的理解水平. 一. 一道考察异步知识的面试题 题目是这样的,要求写出下面代码的输出: setTimeout(() => { co ...

  4. [Go] golang缓冲通道实现资源池

    go的pool资源池:1.当有多个并发请求的时候,比如需要查询数据库2.先创建一个2个容量的数据库连接资源池3.当一个请求过来的时候,去资源池里请求连接资源,肯定是空的就创建一个连接,执行查询,结束后 ...

  5. 814-Binary Tree Pruning

    Description: We are given the head node root of a binary tree, where additionally every node’s value ...

  6. 2018/12/21:Date类

    1.Date类 getDate()返回一个月的某一天 1-31 getDay()返回一周的某一天 getFullyear()返回四位数的年份 getMonth()返回月份 比实际情况小 1 0代表1月 ...

  7. 2018.12/17 function 的闭包

    1.闭包:函数在调用的时候会形成一个私有的作用域,对内部变量起到保护的作用,这就是闭包. 2.变量销毁: 1.人为销毁  var a=12; a=null 2.自然销毁  函数调用完成之后 浏览器会自 ...

  8. 前端项目git操作命名规范和协作开发流程

    前言 一个项目的分支,一般包括主干 master 和 开发分支 dev,以及若干临时分支 分支命名规范 分支: 命名: 说明: 主分支 master 主分支,所有提供给用户使用的正式版本,都在这个主分 ...

  9. 2019-01-28 [日常]Beyond的歌里最多是"唏嘘"吗? - Python分词+词频

    看了一个Beyond的纪录片, 提到这个. 觉得心有不甘, 于是搜集了24首歌词, 用Python做了简单分词和词频统计. 源码(包括歌词)在: program-in-chinese/study 统计 ...

  10. vue 路由的使用

    ue-router是Vue.js官方的路由插件,它和vue.js是深度集成的,适合用于构建单页面应用.vue的单页面应用是基于路由和组件的,路由用于设定访问路径,并将路径和组件映射起来.传统的页面应用 ...