当前位置:  编程技术>移动开发
本页文章导读:
    ▪【struts2】赵雅智_Struts2中结果集门类        【struts2】赵雅智_Struts2中结果集类型整合Hibernate技术 分析的servlet    客户端--->web容器-->web.xml -->servlet来处理 ----->model-->数据库      <--------------------------------| request.setA.........
    ▪ 增添textField到tableviewheader        添加textField到tableviewheader- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 30.0; } -(UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *tableH.........
    ▪ 掌握技巧       掌握技能 AIDL, UML, 设计模式, 数据结构, 算法, ......

[1]【struts2】赵雅智_Struts2中结果集门类
    来源: 互联网  发布时间: 2014-02-18
【struts2】赵雅智_Struts2中结果集类型

整合Hibernate技术

分析的servlet

   客户端--->web容器-->web.xml -->servlet来处理 ----->model-->数据库

     <--------------------------------|

request.setAttribute(“username”,username);

//转发

request.getDis(“manager/index.jps”).forward(request,response);

       ---在jsp页面中  ${username}

//重定向

response.sendRiedirect();

分析 struts2

客户端----->web容器--->web.xml-->struts2过滤器--->struts.xml--->Action--->model--->数据库

 <------------------------------------------------|

Action  要想把数据 传递给jsp

     private String username;

      public String getUsername(){return username;}

 通过什么方式传递 

   <result type="dispatcher" name="success">/manager/index.jsp</result>

Jsp =---〉 ${username}

Struts2中结果集类型

1、 每个action方法都返回一个String类型的值,struts一次请求返回什么值是由这个值确定的。

2、 在配置文件中,每一个action元素的配置都必须有result元素,每一个result对应一个action的返回值。

3、 Result有两个属性:

name:结果的名字,和action中的返回值一样,默认值为success;

type:响应结果类型,默认值为dispatcher.

在下面找到struts-default.xml文件中,如下面所示:

             

说明:

1、 从上述可以看出总共10种类型

2、 默认类型为ServletDispatcherResult即转发。

3、 结果类型可以是这10种结果类型的任意一种。

Dispatcher类型 (1)、 说明

Dispatcher类型是最常用的结果类型,也是struts框架默认的结果类型。

(2)、 例子

页面参照:/manager/index.jsp

Action参照:AdminAction

配置文件: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="test" namespace="/csdn" extends="struts-default">


		<action name="adminLogin" 
			method="login">
			<!--
				第一种写法 <result name="success">/manager/index.jsp</result>
			-->
			<!-- 第二种写法 -->
			<result name="success">
				<param name="location">/manager/index.jsp</param>
			</result>
			<result name="login">/index.jsp</result>
		</action>


	</package>




</struts>

package www.csdn.project.action;

import www.csdn.project.dao.AdminDAO;
import www.csdn.project.dao.AdminDAOImpl;
import www.csdn.project.domain.Admin;
import www.csdn.project.service.AdminService;
import www.csdn.project.service.AdminServiceImpl;

import com.opensymphony.xwork2.ActionSupport;

public class AdminAction extends ActionSupport {

	private String adminName;
	private String adminPassword;
	private Admin entity;

	private AdminService adminService = new AdminServiceImpl();

	public void setAdminName(String adminName) {
		this.adminName = adminName;
	}

	public void setAdminPassword(String adminPassword) {
		this.adminPassword = adminPassword;
	}

	public Admin getEntity() {
		return entity;
	}

	public String login() {
		entity = adminService.login(adminName, adminPassword);
		if (entity != null) {
			return SUCCESS;
		} else {
			return LOGIN;
		}
	}
	
	public String insert() {
		boolean b = false;
		b = adminService.add(entity);
		
		if(b) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}


}


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="/blog_article/<%=basePath%>/index.html">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="/blog_article/styles.css">
	-->
	</head>

	<body>
		<div align="center">
			<h3>
				后台管理登陆界面
			</h3>

			<hr />

			<form
				action="/blog_article/${pageContext.request.contextPath}/csdn/adminLogin.action"
				method="post">
				用户名:
				<input type="text" name="adminName" />
				<br />
				密  码:
				<input type="password" name="adminPassword" />
				<br />
				<input type="submit" value="Login" />

			</form>
		</div>
	</body>
</html>


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="/blog_article/<%=basePath%>/index.html">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="/blog_article/styles.css">
	-->
	</head>

	<body>
		<div align="center">
			<h3> 
				欢迎${entity.adminName}后台管理界面! 
			</h3><br><br>
			
		</div>
	</body>
</html>


下面的图说明了location的来历:

Redirect类型 (1)、 说明

Redirect属于重定向。如果用redirect类型,则在reuqest作用域的值不能传递到前台。

(2)、 例子

页面参照:/manager/index.jsp

Action参照:AdminAction

配置文件: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="test" namespace="/csdn" extends="struts-default">


		<action name="adminLogin" 
			method="login">


			<!--第一种写法
			
				<result name="success" type="redirect">/manager/index.jsp</result>
			-->
			<!-- 第二种写法 -->
			<result name="success" type="redirect">
				<param name="location">/manager/index.jsp</param>
			</result>
			<result name="login">/index.jsp</result>
		</action>


	</package>


</struts>

package www.csdn.project.action;

import www.csdn.project.dao.AdminDAO;
import www.csdn.project.dao.AdminDAOImpl;
import www.csdn.project.domain.Admin;
import www.csdn.project.service.AdminService;
import www.csdn.project.service.AdminServiceImpl;

import com.opensymphony.xwork2.ActionSupport;

public class AdminAction extends ActionSupport {

	private String adminName;
	private String adminPassword;
	private Admin entity;

	private AdminService adminService = new AdminServiceImpl();

	public void setAdminName(String adminName) {
		this.adminName = adminName;
	}

	public void setAdminPassword(String adminPassword) {
		this.adminPassword = adminPassword;
	}

	public Admin getEntity() {
		return entity;
	}

	public String login() {
		entity = adminService.login(adminName, adminPassword);
		if (entity != null) {
			return SUCCESS;
		} else {
			return LOGIN;
		}
	}
	
	public String insert() {
		boolean b = false;
		b = adminService.add(entity);
		
		if(b) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}


}


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="/blog_article/<%=basePath%>/index.html">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="/blog_article/styles.css">
	-->
	</head>

	<body>
		<div align="center">
			<h3>
				后台管理登陆界面
			</h3>

			<hr />

			<form
				action="/blog_article/${pageContext.request.contextPath}/csdn/adminLogin.action"
				method="post">
				用户名:
				<input type="text" name="adminName" />
				<br />
				密  码:
				<input type="password" name="adminPassword" />
				<br />
				<input type="submit" value="Login" />

			</form>
		</div>
	</body>
</html>


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="/blog_article/<%=basePath%>/index.html">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="/blog_article/styles.css">
	-->
	</head>

	<body>
		<div align="center">
			<h3> 
				欢迎${entity.adminName}后台管理界面! 
			</h3><br><br>
			
		</div>
	</body>
</html>




redirectAction类型 (1)、说明

1、 把结果类型重新定向到action

2、 可以接受两种参数

a) actionName: action的名字

b) namespace:命名空间

(2)、 例子

在配置文件中

<?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="test" namespace="/csdn" extends="struts-default">


		<action name="adminLogin" 
			method="login">


			<!--
				<result name="success" type="redirectAction"> <param
				name="actionName">delete.action</param> <param
				name="namespace">/csdn</param> </result>
			-->


			<result name="success" type="redirectAction">csdn/delete.action?name=${entity.adminName}
			</result>


			<result name="login">/index.jsp</result>


		</action>


		<action name="delete"
			
			method="delete">
			<result>/index.jsp</result>
		</action>


	</package>




</struts>

package www.csdn.project.action;

import www.csdn.project.dao.AdminDAO;
import www.csdn.project.dao.AdminDAOImpl;
import www.csdn.project.domain.Admin;
import www.csdn.project.service.AdminService;
import www.csdn.project.service.AdminServiceImpl;

import com.opensymphony.xwork2.ActionSupport;

public class AdminAction extends ActionSupport {

	private String adminName;
	private String adminPassword;
	private Admin entity;

	private AdminService adminService = new AdminServiceImpl();

	public void setAdminName(String adminName) {
		this.adminName = adminName;
	}

	public void setAdminPassword(String adminPassword) {
		this.adminPassword = adminPassword;
	}

	public Admin getEntity() {
		return entity;
	}

	public String login() {
		entity = adminService.login(adminName, adminPassword);
		if (entity != null) {
			return SUCCESS;
		} else {
			return LOGIN;
		}
	}
	
	public String insert() {
		boolean b = false;
		b = adminService.add(entity);
		
		if(b) {
			return SUCCESS;
		} else {
			return ERROR;
		}
	}


}

package www.csdn.project.actionreslut.test.action;

import com.opensymphony.xwork2.ActionSupport;

public class DeleteAction extends ActionSupport {
	
	private String name;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String delete(){
		
		System.out.println("删除成功......");
		
		return SUCCESS;
	}

}


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="/blog_article/<%=basePath%>/index.html">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="/blog_article/styles.css">
	-->
	</head>

	<body>
		<div align="center">
			<h3>
				后台管理登陆界面
			</h3>

			<hr />

			<form
				action="/blog_article/${pageContext.request.contextPath}/csdn/adminLogin.action"
				method="post">
				用户名:
				<input type="text" name="adminName" />
				<br />
				密  码:
				<input type="password" name="adminPassword" />
				<br />
				<input type="submit" value="Login" />

			</form>
		</div>
	</body>
</html>


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="/blog_article/<%=basePath%>/index.html">

		<title>My JSP 'index.jsp' starting page</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="/blog_article/styles.css">
	-->
	</head>

	<body>
		<div align="center">
			<h3> 
				欢迎${entity.adminName}后台管理界面! 
			</h3><br><br>
			
		</div>
	</body>
</html>





    
[2] 增添textField到tableviewheader
    来源: 互联网  发布时间: 2014-02-18
添加textField到tableviewheader
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 30.0;
}

    -(UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(40, 0, self.view.frame.size.width - 70, 30)];
    tableHeaderView.backgroundColor =[UIColor grayColor];
    UITextField *sectionTitleTF1 = [[UITextField alloc] initWithFrame:CGRectMake(58, 0, 500, 30)];
    sectionTitleTF1.backgroundColor = [UIColor whiteColor];
    [sectionTitleTF1 setBackgroundColor:[UIColor whiteColor]];
    [sectionTitleTF1 setFont:[UIFont boldSystemFontOfSize:15]];
    [sectionTitleTF1 setBorderStyle:UITextBorderStyleLine];
    [sectionTitleTF1 setTextAlignment:UITextAlignmentCenter];
    [sectionTitleTF1 setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
    [sectionTitleTF1 becomeFirstResponder];
    [tableHeaderView addSubview:sectionTitleTF1];
    return tableHeaderView;
    }


    
[3] 掌握技巧
    来源: 互联网  发布时间: 2014-02-18
掌握技能

AIDL,

UML,

设计模式,

数据结构,

算法,


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3