我们都知道 struts2 是基于webframework 出现的 优秀的mvc 框架, 他和struts1 完全没有联系。struts2 是一个框架, 啥叫框架呢?是一个优秀的半成品 。

web的框架在java 中有 webframework  struts2  springmvc。。。。

struts2 和struts1 区别

1、没有任何联系

2、struts2内核是webframework

demo1:

struts2 的入门demo:

1、web框架的过滤器

     <!-- struts 定义核心的filter filtedispatcher  -->
<filter>
<filter-name>sruts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sruts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

web.xml 中设定过滤器

2、书写一个一般的 struts  class

 package cn.jiemoxiaodi.demo1;

 /***********************
*
* @author huli
*
* @version 1.0
*
* @created 2016-6-27
*
***********************
*/ public class Struts2Demo1 {
public String execute() {
System.out.println("dddd");
return "success";
}
}

Struts2Demo1

3、 在jsp页面中 请求的 struts2 默认格式是 ???.action

<a href="${pageContext.request.contextPath}/demo1.action">goto struts2 demo
success</a>

4、配置action 到那个页面去

我们会在 src 文件价下创建struts.xml(固定名字)

 <?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="demo1" extends="struts-default">
<action name="demo1" class="cn.jiemoxiaodi.demo1.Struts2Demo1">
<result name="success">/demo1/success.jsp</result>
</action>
</package>
</struts>

action mapping

好了

struts2 基础demo1的更多相关文章

  1. Struts2基础学习2

    Struts2基础学习2 项目结构,测试页面与实体类 <%@ page language="java" contentType="text/html; charse ...

  2. Struts2入门1 Struts2基础知识

    Struts2入门1 Struts2基础知识 20131130 代码下载: 链接: http://pan.baidu.com/s/11mYG1 密码: aua5 前言: 之前学习了Spring和Hib ...

  3. Struts2基础入门

    Struts2基础入门 创建一个web工程 0)导包并且创建一个核心配置文件 <?xml version="1.0" encoding="UTF-8"?& ...

  4. Struts2基础学习总结

    引用自:http://www.cnblogs.com/jbelial/archive/2012/05/10/2486886.html Struts 2是在WebWork2基础发展而来的. 注意:str ...

  5. struts2&&Hibernate Demo1

    这篇文章和<struts1&&Hibernate Demo1>基本类似,我这里只是拷贝代码了. 最核心的代码:LoginAction.java package action ...

  6. 经典MVC框架技术-struts2基础知识

    Struts2框架简介 struts2框架是在struts1和webwork技术的基础上,进行合并的全新框架,struts2以Webwork为核心,采用拦截器来处理用户的请求,这样的设计使得业务逻辑控 ...

  7. Struts2框架学习第三章——Struts2基础

    本章要点 —  Struts 1框架的基本知识 — 使用Struts 1框架开发Web应用 —  WebWork框架的基本知识 — 使用WebWork框架开发Web应用 — 在Eclipse中整合To ...

  8. struts2基础代码实现

    结构图: load.jsp <%@ page language="java" import="java.util.*" pageEncoding=&quo ...

  9. (一)Struts2 基础

    一.Struts简介 1.1 历史 虽然Struts 2号称是一个全新的框架,但这仅仅是相对Struts 1而言.Struts 2与Struts 1相比,确实有很多革命性的改进,但它并不是新发布的新框 ...

随机推荐

  1. Web Pages - Efficient Paging Without The WebGrid

    Web Pages - Efficient Paging Without The WebGrid If you want to display your data over a number of p ...

  2. Linux环境PHP5.5以上连接SqlServer2008【全网最经典无错版】

    原文地址:http://blog.csdn.net/21aspnet/article/details/47451253 linux版本:64位CentOS 6.4 Nginx版本:nginx1.8.0 ...

  3. asp.net mvc @Html.Partial @Html.Action @Html.RenderPartial @Html.RenderAction区别

    转载自 :  <asp.net mvc @Html.Partial @Html.Action @Html.RenderPartial @Html.RenderAction区别> 先复制过来 ...

  4. jQuery parent.append和$after的区别

    首先假设我们有个id为test的div和一个id为test2的div: <div id="test">     我是测试div </div> <div ...

  5. mapreduce 模板

    /*** * MapReduce Module * @author nele * */ public class ModuleMapReduce extends Configured implemen ...

  6. MySQL 中NULL和空值的区别

    平时我们在使用MySQL的时候,对于MySQL中的NULL值和空值区别不能很好的理解.注意到NULL值是未知的,且占用空间,不走索引,DBA建议建表的时候最好设置字段是NOT NULL 来避免这种低效 ...

  7. 数论只会GCD。。。

    一些关于GCD的代码.... #include <iostream> #include <cstdio> #include <cstring> using name ...

  8. 2013nanjignB

    B - Poor Warehouse Keeper Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & ...

  9. LUXURY 8

    A - Gargari and Bishops Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  10. Linux之服务器时间同步

    Linux时间同步(把nameNode1作为时间同步服务器) 设置时区 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 联网情况:ntpdate ...