struts2的struts.xml简单介绍
来源:互联网 发布:300339润和软件 编辑:程序博客网 时间:2024/05/17 09:17
啊 昨天其实就发现了的,struts的MVC结构非常的正规,感觉这样处理起来确实是将各个问题都分开解决了,谁也不会影响谁的,后台的处理后台,前台的处理前台。关于这里的链接这些东西的就是struts.xml了,这个东西是非常重要的,你要配置好这个xml文件才能将整个MVC架构起来!
下面说一下,几个比较重要的知识点:第一、就是默认的action,就是如果没有找到对应的action,你要访问那个界面,通常我们是要报错的,那么你就可以设置一个简单的报错网页,随时告知自己是action没有导致的,对于找错误也是很有帮助的;第二、result中的type值,可以设置result动作的类型,当然redirect是最好的,我认为,当然也要根据具体的情况来说。第三、通配符的使用,这个也是很方便的,如果你的result返回的网页就那么几个网页,或者action的名字和method有一些关系,那通配符是一个好东西的。第四、global-results不能和default-action-ref一起用,这个不知道是怎么回事,网上没有找到答案。
把我的struts.xml一起拿出来下次看吧:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts><constant name="struts.devMode" value="true"></constant> <!-- 发布的时候是要把这个false掉的 --><package name="struts2" extends="struts-default" ><!-- <global-results><result name="error" type="redirect">/chapter8/error.jsp</result></global-results>--> <!-- 这个和defult-action-ref不能一起用 --><default-action-ref name="forwardaction">apter8/error.jsp</default-action-ref><action name="forwardaction" class="chapter8.action.DefaultAction"><result name="error" type="redirect">apter8/error.jsp</result></action><action name="login" class="chapter8.action.QueryAction" method="login"><result name="loginsuccess" >/chapter8/loginsuccess.jsp</result><result name="loginnotfound">/chapter8/loginnotfound.jsp</result></action><action name="register" class="chapter8.action.QueryAction" method="register"><result name="registersuccess">/chapter8/registersuccess.jsp</result></action></package></struts>
- struts2的struts.xml简单介绍
- 简单的struts2.0配置struts.xml
- struts2 的struts.xml配置
- struts2 struts.xml的结构
- struts2的struts.xml配置
- struts2的struts.xml struts.properties配置文件
- struts的简单介绍
- Struts2的简单介绍
- struts2.0 struts.xml和STRUTS的config.xml详解
- struts2.0 struts.xml和STRUTS的config.xml详解
- struts2.0 struts.xml和STRUTS的config.xml详解
- struts2.0 struts.xml和STRUTS的config.xml详解
- struts2的配置文件struts.xml的位置
- struts2的完整的struts.xml骨架
- Struts2的配置文件的配置struts.xml
- [Struts2]struts.xml中result的path
- struts2配置文件struts.xml的目录问题
- struts2.0的struts.xml配置文件详解
- RTCP 详解1
- 林志颖VS方舟子 Linboss从容应对显智慧【转】
- If-Modified-Since in HTTP headers
- Memcahed分布式缓存服务替换Session解决方案
- 杨辉三角
- struts2的struts.xml简单介绍
- 位域
- JavaWeb学习__第4天__response与request
- server的端口号
- #pragam once 和 #ifndef 预编译头
- Objective-c的@property 详解
- mkdir 系统调用
- U盘安装Fedora-18-x86_64-DVD.iso的过程
- 将U盘格式成UTFS格式