我们都知道 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. PHP isset 函数作用

    isset函数是检测变量是否设置. 格式:bool isset ( mixed var [, mixed var [, ...]] ) 返回值: 若变量不存在则返回 FALSE 若变量存在且其值为NU ...

  2. Asp.Mvc中的text实现 辅助用户输入 灰色字体

    在开发Web应用程序中经常需要用户在文本框输入信息,为了提高程序人性化设置以及用户体验效果常常需要在文本框中显示灰色字体辅助用户输入 如:

  3. [Angularjs]表单验证

    写在前面 在开发中提交表单,并对表单的值进行验证是非常常见的操作,angularjs对表单验证提供了非常好的支持. demo 表单 <form name="myform" n ...

  4. 如何在发布博客时插入复杂公式——Open Live Writer

    1.http://latex.codecogs.com/eqneditor/editor.php 2.使用Word发布

  5. 清北暑假模拟day1 爱

    /* 水题 */ #include<iostream> #include<cstdio> #include<string> #include<cstring& ...

  6. redis-string-统计

    package com.ztest.redis.string; import org.junit.Test; import redis.clients.jedis.Jedis; import com. ...

  7. 21个免费的UI设计工具和资源网站,不管是web,js,android都

    本帖最后由 hua631150873 于 2014-9-12 18:26 编辑 Lumzy 官方地址:http://www.lumzy.com/ Lumzy是一个网站应用和原型界面制作工具.使用Lum ...

  8. Unity3D性能优化--- 收集整理的一堆

    http://www.cnblogs.com/willbin/p/3389837.html 官方优化文档--优化图像性能http://docs.unity3d.com/Documentation/Ma ...

  9. tableView 选中cell时,获取到当前cell

    // >> 找到当前选中的cell,设置选中时的cell背景色 SideTableViewCell * cell = (SideTableViewCell *)[tableView cel ...

  10. 给UIView添加手势

    对于不能addTarget的UI对象,添加手势为他们带来了“福音”,以为UIView添加手势为例,揭开手势的面目. 1,创建一个view先, UIView * jrView=[[UIViewalloc ...