struts2根据struts2完全学习手册 自己总结_struts2完全教程总结
struts2根据struts2完全学习手册 自己总结由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“struts2完全教程总结”。
一、struts2简介struts2的配置文件:
(1)struts.xml 配置示例:
“-//Apache Software Foundation//DTD Struts Configuration 2.0//EN”
“http://struts.apache.org/dtds/struts-2.0.dtd”>
HelloWorld
/example
(2)struts.properties配置文件 # # $Id: struts.properties 722328 2008-12-02 01:56:24Z davenewton $ # # Licensed to the Apache Software Foundation(ASF)under one # or more contributor license agreements.See the NOTICE file # distributed with this work for additional information # regarding copyright ownership.The ASF licenses this file # to you under the Apache License, Version 2.0(the # “License”);you may not use this file except in compliance # with the License.You may obtain a copy of the License at # # http://www.daodoc.com/
struts2控制器
(1)核心控制器: FilterDispatcher(在web应用中负责拦截所有的用户请求)
如果用户的请求以.ation结尾,则该请求被转入struts2框架处理。
(2)业务控制器: Action(在struts2中起作用的实际上不是用户自定义的Action,而是系统自动生成的action代理,但该代理是以用户自定义的action为目标的)Action 举例:
package com.user.action;
public cla Login {
} 由以上代码可知:struts2中的action完全是普通的java类。Struts2中action接口不是必须实现的,任何包含有execute()方法的pojo(plain ordinary java object)private String userName;private String paword;public String getUserName(){ } public void setUserName(String userName){ } public String getPaword(){ } public void setPaword(String paword){ }
public String excute(){
} if(“admin”.equals(userName)&&(“paword”.equals(paword))){
} return “succe”;return “error”;}else{ this.paword = paword;return paword;this.userName = userName;return userName;对象都可以作为struts2的action对象。struts2标签库
<%@ page language=“java” import=“java.util.*” pageEncoding=“gbk”%> <%@ taglib prefix=“s” uri=“/struts-tags”%>(引入struts标签)
struts2标签
通讯录
Struts2面试题1、struts2工作流程Struts 2框架本身大致可以分为3个部分:核心控制器FilterDispatcher、业务控制器Action和用户实现的企业业务逻辑组件。 核心控制器FilterDis......
搭建Struts2环境时:1找到开发Struts2应用需要使用到的jar文件.2编写Struts2的配置文件3在web.xml中加入Struts2 MVC框架启动配置大家可以到http://struts.apache.org/downloa......
struts2知识总结1.全局的逻辑控制器为一个过滤器,负责过滤所有的请求。该过滤器引用的API类为org.apache.struts2.disapatcher.FilterDispatcher 2.MVC:页面请求(jsp)——>......
—高级软件人才实作培训专家!Struts2的启动配置在struts1.x中,struts框架是通过Servlet启动的。在struts2中,struts框架是通过Filter启动的。他在web.xml中的配置如下:struts2o......
Struts2集成指南关于Struts2 Struts是Apache软件基金会(ASF)赞助的一个开源项目。它最初是Jakarta项目中的一个子项目,并在2004年3月成为ASF的顶级项目。它通过采用Java Servle......
