1.所需类库

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
</dependency> <dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.4.1</version>
</dependency> <dependency>
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
<version>2.3.4.1
</version>
</dependency> 2.配置web-xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app>
<display-name>Archetype Created Web Application</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>
</web-app> 3.配置文件
<?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="default" namespace="/" extends="struts-default">
<action name="userAction" class="cn.happy.action.UserAction">
<result name="success">/success.jsp</result>
</action>
</package>
</struts>
4.所需jsp页面
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<s:form method="POST" action="userAction">
<%--性能低--%>
请输入用户名: <s:textfield name="username"></s:textfield> <br/>
<s:textfield name="password"></s:textfield><br/>
<s:submit value="登陆"></s:submit>
</s:form>
</body>
</html> 5.配置action
package cn.happy.action;

import com.opensymphony.xwork2.Action;

/**
* Created by Happy on 2017-10-22.
* 类 Action
*/
public class UserAction implements Action{
//SpringMvc Controller
public String execute() throws Exception {
return SUCCESS;
}
}
6.项目部署,运行即可

初学struts2-入门案列的更多相关文章

  1. 初学spring之入门案列

    spring其实是一个很大的开源框架,而我学的就是spring framework,这只是spring其中的一小部分.有疑惑的可以去官网去看看,spring官网我就不提供了.一百度肯定有.和sprin ...

  2. Hadoop入门案列,初学者Coder

    1.WordCount Job类: package com.simope.mr.wcFor; import org.apache.hadoop.conf.Configuration; import o ...

  3. Quartz经典入门案列

    一.Quartz简介 Quartz是一个开放源码项目,专注于任务调度器,提供了极为广泛的特性如持久化任务,集群和分布式任务等.Spring对Quartz的集成与其对JDK Timer的集成在任务.触发 ...

  4. js闭包的作用域以及闭包案列的介绍:

    转载▼ 标签: it   js闭包的作用域以及闭包案列的介绍:   首先我们根据前面的介绍来分析js闭包有什么作用,他会给我们编程带来什么好处? 闭包是为了更方便我们在处理js函数的时候会遇到以下的几 ...

  5. Spring MVC的配置文件(XML)的几个经典案列

    1.既然是配置文件版的,那配置文件自然是必不可少,且应该会很复杂,那我们就以一个一个的来慢慢分析这些个经典案列吧! 01.实现Controller /* * 控制器 */ public class M ...

  6. Struts2 入门

    一.Struts2入门案例 ①引入jar包 ②在src下创建struts.xml配置文件 <?xml version="1.0" encoding="UTF-8&q ...

  7. SAMSUNG某型号一千短信成功记录!对比其他软件恢复不成功的案列!

    Hello! 大家好欢迎再次来到Dr.wonde的博客, 下面谈一下今天的案列,今年11月26号收到了一客户寄来的三星S4手机恢复里面短信, 如下图所示,用其他软件恢复以后,数据为零,没有恢复,,这下 ...

  8. php知识案列分享

    今天再跟大家分享一下,以下案列. 使用array_flip函数生成随机数,可以去掉重复值. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 < ...

  9. linux下mysql函数的详细案列

    MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, const char *user, const char *pas ...

随机推荐

  1. [转载][效率工具推荐]Mathpix – 将图片数学公式转换为 LaTeX

    转自小众软件:Mathpix – 将图片数学公式转换为 LaTeX Mathpix 是一款跨平台(Windows.macOS.Linux)的 OCR 工具,它能够识别复杂的数学公式,并将其转换为 La ...

  2. java处理中日文字符串的乱码问题

    ——杂言:前段时间在处理音频预览问题,详见关于audiojs的研究.期间,将远端的音频下载并缓存在本地过程中,涉及到java.io.*的几个操作,发生一些乱码问题. 我以前的处理是将本地的编码转换为U ...

  3. LDA与最小二乘法的关系及其变种详解

    1 LDA与最小二乘法的关联 对于二值分类问题,令人惊奇的是最小二乘法和LDA分析是一致的.回顾之前的线性回归,给定N个d维特征的训练样例(i从1到N),每个对应一个类标签.我们之前令y=0表示一类, ...

  4. 【机器学习】分类器组合——AdaBoost

    AdaBoost是一种迭代算法,其核心思想是针对同一个训练集训练不同的分类器(弱分类器),然后把这些弱分类器集合起来,构成一个更强的最终分类器(强分类器). AdaBoost其实只是boost的一个特 ...

  5. Entity Framework Code-First(9.2):DataAnnotations - TimeStamp Attribute

    DataAnnotations - TimeStamp Attribute: TimeStamp attribute can be applied to only one byte array pro ...

  6. Spring JdbcTemplate+JdbcDaoSupport实例(和比较)

    首先,数据库是这样的,很简单. 当然,要引入spring的包,这里我全部导入了,省事. applicationContext.xml是这样的: <?xml version="1.0&q ...

  7. 计算像素亮度(Pixel Light)

    RGB有亮度吗?常用公式: Y(亮度)=(0.299*R)+(0.587*G)+(0.114*B)

  8. 关于.net Core项目发布在Linux上的填坑

    本文主要记录.net Core项目发布在Linux服务器上面所遇到的问题,防止遗忘是 1.在发布文件中执行 dotnet xxxxxx.dll的时候提示如下错误: An assembly specif ...

  9. The instance of entity type 'xxxx' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked.

    一.问题描述 问题:The instance of entity type 'xxxx' cannot be tracked because another instance with the sam ...

  10. EasyUI 在mvc中的引入与使用

    使用步骤: 一.先引入: 1.easyui下载,可以去官方网站去下载最新版EasyUI官方下载地址:http://www.jeasyui.com/download/index.php 2.下载后解压, ...