Struts2(二)--Servlet API及数据封装

Struts2框架下访问Servlet API的多种策略 Struts2框架是Java领域中用于开发Web应用的成熟框架之一,它基于MVC模式,极大地简化了Java Web应用的开发。在深入了解Struts2的高级用法之前,首先需要对Struts2的执行流程有一个总体的认识。ActionContext是Struts2框架中用来存储Action执行过程中所需的数据和对象的一个容器。它是Action类的执行上下文,为Action提供了一个灵活的操作环境。 阅读详情

一、Servlet的API访问

Struts2和Servlet的API为解耦合的。如果要使用涉及到Servlet的API则 使用一下方式访问

1.1 Servlet的API访问方式

  • 完全解耦合的方式

只能存取值,不能像Servlet中request,session,application一样可以有别的方法

Action类的编写:

package com.struts2Demo_02.demo01;

import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 访问Servlet的API方式一:完全解耦合方式
 * @author cf
 *
 */
public class RequestDemo01 extends ActionSupport{

	@Override
	public String execute() throws Exception {
		//接受参数
		//利用struts2中的对象ActionContext对象
		ActionContext context = ActionContext.getContext();
		//调用ActionContext中的方法
		Map<String, Object> map = context.getParameters();
		for (Entry<String, Object> entry: map.entrySet()) {
			System.out.println(entry.getKey());
			System.out.println(Arrays.toString((String[])entry.getValue()));
		}
		
		//向域对象中存入数据
		context.put("reqName", "reqValue"); //相当于request.setAttribute();
		context.getSession().put("sessName", "sessValue");//相当于session.setAttribute();
		context.getApplication().put("appName", "appValule");//相当于application.setAttribute();
		
		
		return SUCCESS;
	}
}

跳转至success.jsp页面:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>显示数据</h1>
<h3>request中的数据</h3>
${reqName }
<h3>session中的数据</h3>
${sessName }
<h3>application中的数据</h3>
${appName }

</body>
</html>

结果如下:

在这里插入图片描述

  • 使用Servlet的API的原生方式

使用原生方式

 package com.struts2Demo_02.demo01;
    
    import java.util.Arrays;
    import java.util.Map;
    import java.util.Map.Entry;
    
    import javax.servlet.http.HttpServletRequest;
    
    import org.apache.struts2.ServletActionContext;
    
    import com.opensymphony.xwork2.ActionSupport;
    
    public class RequestDemo02 extends ActionSupport {
    	@Override
    	public String execute() throws Exception {
    		//接受数据
    		//通过ServletActionContext接受
    		HttpServletRequest request = ServletActionContext.getRequest();
    		Map<String, String[]> map = request.getParameterMap();
    		for (Entry<String, String[]> entry : map.entrySet()) {
    			System.out.println(entry.getKey());
    			System.out.println(Arrays.toString(entry.getValue()));
    		}
    		
    		//向域中保存数据
    		//向request中保存数据
    		request.setAttribute("reqName", "reqValue");
    		//向session中保存数据
    		request.getSession().setAttribute("sessName", "sessValue");
    		//向application中保存数据
    		ServletActionContext.getServletContext().setAttribute("appName", "appValue");
    		
    		return SUCCESS;
    	}
    }
  • 接口注入的方式

需要实现相关的对应接口

package com.struts2Demo_02.demo01;

import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.catalina.tribes.util.Arrays;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.util.ServletContextAware;

import com.opensymphony.xwork2.ActionSupport;
/**
 * 方式三:接口注入
 * @author cf
 *
 */
public class RequestDemo03 extends ActionSupport implements ServletRequestAware, ServletContextAware{

	private HttpServletRequest request;
	private ServletContext context;

	@Override
	public String execute() throws Exception {
		//接收参数
		//通过接口注入的方式获得request对象
		Map<String, String[]> map = request.getParameterMap();
		for (Entry<String, String[]> entry : map.entrySet()) {
			System.out.println(entry.getKey());
			System.out.println(Arrays.toString(entry.getValue()));
		}
		
		//向域中保存数据
		request.setAttribute("reqName", "reqValue");
		//向session中保存数据 
		request.getSession().setAttribute("sessName", "sessValue");
		//向application中保存数据
		context.setAttribute("appName", "appValue");
		
		return SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	@Override
	public void setServletContext(ServletContext context) {
		this.context = context;
	}
	
}

二、结果页面的配置

2.1 全局结果页面

全局结果页面: 在包中配置一次,其他包只要返回相同值,都会跳转到此页面

第一节中的案列,所有的返回结果都一样。可以配置为全局结果页面,如果局部仍配置了返回结果,则局部生效

使用<global-results>标签配置

<?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="demo01" extends="struts-default" namespace="/">
	
		<!-- 全局结果页面 -->
		<global-results>
				<result name="success">/demo01/success.jsp</result>
		</global-results>
	
		<action name="requestDemo01" class="com.struts2Demo_02.demo01.RequestDemo01">
<!-- 					<result name="success">/demo01/success.jsp</result> -->
		</action>	
		
			<action name="requestDemo02" class="com.struts2Demo_02.demo01.RequestDemo02">
<!-- 					<result name="success">/demo01/success.jsp</result> -->
		</action>	
		
		<action name="requestDemo03" class="com.struts2Demo_02.demo01.RequestDemo03">
<!-- 					<result name="success">/demo01/success.jsp</result> -->
		</action>	
	</package>
</struts>

2.2 局部结果页面

局部结果页面:只在当前的action中的配置有效

一下配置,则局部配置有配置的局部配置有效

<?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="demo01" extends="struts-default" namespace="/">
	
		<!-- 全局结果页面 -->
		<global-results>
				<result name="success">/demo01/success.jsp</result>
		</global-results>
	
		<action name="requestDemo01" class="com.struts2Demo_02.demo01.RequestDemo01">
					<result name="success" >/demo01/success.jsp</result>
		</action>	
		
			<action name="requestDemo02" class="com.struts2Demo_02.demo01.RequestDemo02">
<!-- 					<result name="success">/demo01/success.jsp</result> -->
		</action>	
		
		<action name="requestDemo03" class="com.struts2Demo_02.demo01.RequestDemo03">
<!-- 					<result name="success">/demo01/success.jsp</result> -->
		</action>	
	</package>
</struts>

三、数据封装

3.1 属性驱动

  • 提供属性set方法

创建实体类:

product.java

package com.struts2Demo_02.domain;

import java.util.Date;

public class Product {
	private String name;
	private double price;
	private Date time;
	private String category;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
}

demo02.jsp

输入商品参数

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Struts2的数据封装</h1>
<h3>方式一:属性驱动提供set方法</h3>
<form action="${pageContext.request.contextPath }/productAction01.action" method="post">
	商品名称:<input type="text" name="name"><br>
	商品价格:<input type="text" name="price"><br>
	上架时间:<input type="text" name="time"><br>
	商品分类:<input type="text" name="category"><br>
	<input type="submit" value="提交">
</form>
</body>
</html>

Action类

action类中需提供相关属性及set方法

package com.struts2Demo_02.demo02;

import java.util.Date;

import com.opensymphony.xwork2.ActionSupport;
import com.struts2Demo_02.domain.Product;

/**
 * 数据封装方式一:提供属性的set方法
 * @author cf
 *
 */
public class ProductAction01 extends ActionSupport{
	//提供了对应的属性
	private String name;
	private double price;
	private Date time;
	private String category;
	//提供了对应的set方法
	public void setName(String name) {
		this.name = name;
	}


	public void setPrice(double price) {
		this.price = price;
	}


	public void setTime(Date time) {
		this.time = time;
	}


	public void setCategory(String category) {
		this.category = category;
	}
	
	
	@Override
	public String execute() throws Exception {
		//获取数据
		System.out.println(name);
		System.out.println(price);
		System.out.println(time);
		System.out.println(category);
		//封装数据
		Product product = new Product();
		product.setName(name);
		product.setPrice(price);
		product.setTime(time);
		product.setCategory(category);
		return NONE;
	}
}

struts配置:

<?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="demo02" extends="struts-default" namespace="/">
		
		<action name="productAction01" class="com.struts2Demo_02.demo02.ProductAction01">
		
		</action>	
	</package>
</struts>

结果如下:

在这里插入图片描述
在这里插入图片描述

虽然取到了数据,但是需要自己手动封装数据

  • 页面中提供表达式

jsp页面增加:

<h3>方式二:在页面中提供表达式</h3>
<form action="${pageContext.request.contextPath }/productAction02.action" method="post">
	商品名称:<input type="text" name="product.name"><br>
	商品价格:<input type="text" name="product.price"><br>
	上架时间:<input type="text" name="product.time"><br>
	商品分类:<input type="text" name="product.category"><br>
	<input type="submit" value="提交">
</form>

Action类:

创建domain类的对象,提供set和get方法

package com.struts2Demo_02.demo02;

import com.opensymphony.xwork2.ActionSupport;
import com.struts2Demo_02.domain.Product;

/**
 * 属性驱动:页面中使用表达式
 * @author cf
 *
 */

public class ProductAction02 extends ActionSupport {

	//提供一个domain类的对象
	private Product product;
	//提供user的set和get方法
	public Product getProduct() {
		return product;
	}
	
	
	public void setProduct(Product product) {
		this.product = product;
	}
	
	 @Override
	public String execute() throws Exception {
		 System.out.println(product);
		 return NONE;
	 }
}

结果如下:
在这里插入图片描述

3.2 模型驱动

jsp页面

<h3>方式三:模型驱动</h3>
<form action="${pageContext.request.contextPath }/productAction01.action" method="post">
	商品名称:<input type="text" name="name"><br>
	商品价格:<input type="text" name="price"><br>
	上架时间:<input type="text" name="time"><br>
	商品分类:<input type="text" name="category"><br>
	<input type="submit" value="提交">
</form>

Action类:

需实现modeldrvie接口

package com.struts2Demo_02.demo02;


import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.struts2Demo_02.domain.Product;

/**
 * 模型qudong
 * @author cf
 *
 */
public class ProductAction03 extends ActionSupport implements ModelDriven<Product>{

	//需手动提供对象实例
	private Product product = new Product();
	
	@Override
	public String execute() throws Exception {
		System.out.println(product);
		return NONE;
	}

	@Override
	public Product getModel() {
		return product;
	}
}

结果如下:

在这里插入图片描述

四、复杂类型的数据封装

4.1 复杂类型的数据封装

批量向数据库中插入数据,需要在页面中将数据封装到集合中
  • 封装数据到LIst集合中

此种方式需在jsp页面提供list的名称,list创建在Action类,使用以下方式修改jsp的name属性。products为Action类中的list名称

jsp页面如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Struts2的复杂类型的数据封装</h1>
<h3>封装到LIst集合中:批量插入商品</h3>
<form action="${pageContext.request.contextPath }/productAction04.action" method="post">
	商品名称:<input type="text" name="products[0].name"><br>
	商品价格:<input type="text" name="products[0].price"><br>
	上架时间:<input type="text" name="products[0].time"><br>
	商品分类:<input type="text" name="products[0].category"><br>
		商品名称:<input type="text" name="products[1].name"><br>
	商品价格:<input type="text" name="products[1].price"><br>
	上架时间:<input type="text" name="products[1].time"><br>
	商品分类:<input type="text" name="products[1].category"><br>
		商品名称:<input type="text" name="products[2].name"><br>
	商品价格:<input type="text" name="products[2].price"><br>
	上架时间:<input type="text" name="products[2].time"><br>
	商品分类:<input type="text" name="products[2].category"><br>
		商品名称:<input type="text" name="products[3].name"><br>
	商品价格:<input type="text" name="products[3].price"><br>
	上架时间:<input type="text" name="products[3].time"><br>
	商品分类:<input type="text" name="products[3].category"><br>
		商品名称:<input type="text" name="products[4].name"><br>
	商品价格:<input type="text" name="products[4].price"><br>
	上架时间:<input type="text" name="products[4].time"><br>
	商品分类:<input type="text" name="products[4].category"><br>
	<input type="submit" value="提交">
</form>
</body>
</html>

Action类如下:

ProductAction04.java

package com.struts2Demo_02.demo02;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.struts2Demo_02.domain.Product;

/**
 * 复杂数据封装至list中
 * @author cf
 *
 */
public class ProductAction04 extends ActionSupport{
	//封装数据至list中,需先创建list
	private List<Product> products;
	//提供集合的get/set方法
	public void setProducts(List<Product> products) {
		this.products = products;
	}
	
	public List<Product> getProducts() {
		return products;
	}

	@Override
	public String execute() throws Exception {
		for (Product product : products) {
			System.out.println(product);
		}
		
		return NONE;
	}	
}

结果如下:

在这里插入图片描述
在这里插入图片描述

  • 封装数据到Map集合中

与list方法有些类似

jsp页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h'two'>Struts'three'的复杂类型的数据封装</h'two'>
<h'four'>封装到Map集合中:批量插入商品</h'four'>
<form action="${pageContext.request.contextPath }/productAction05.action" method="post">
	商品名称:<input type="text" name="map['one'].name"><br>
	商品价格:<input type="text" name="map['one'].price"><br>
	上架时间:<input type="text" name="map['one'].time"><br>
	商品分类:<input type="text" name="map['one'].category"><br>
		商品名称:<input type="text" name="map['two'].name"><br>
	商品价格:<input type="text" name="map['two'].price"><br>
	上架时间:<input type="text" name="map['two'].time"><br>
	商品分类:<input type="text" name="map['two'].category"><br>
		商品名称:<input type="text" name="map['three'].name"><br>
	商品价格:<input type="text" name="map['three'].price"><br>
	上架时间:<input type="text" name="map['three'].time"><br>
	商品分类:<input type="text" name="map['three'].category"><br>
		商品名称:<input type="text" name="map['four'].name"><br>
	商品价格:<input type="text" name="map['four'].price"><br>
	上架时间:<input type="text" name="map['four'].time"><br>
	商品分类:<input type="text" name="map['four'].category"><br>
		商品名称:<input type="text" name="map['five'].name"><br>
	商品价格:<input type="text" name="map['five'].price"><br>
	上架时间:<input type="text" name="map['five'].time"><br>
	商品分类:<input type="text" name="map['five'].category"><br>
	<input type="submit" value="提交">
</form>
</body>
</html>

Action类:

package com.struts2Demo_02.demo02;

import java.util.Map;
import java.util.Map.Entry;

import com.opensymphony.xwork2.ActionSupport;
import com.struts2Demo_02.domain.Product;

/**
 * 复杂数据的封装,封装至map集合
 * @author cf
 *
 */
public class ProductAction05 extends ActionSupport{
	//县创建map
	private Map<String, Product> map;
	//提供get和set方法
	public Map<String, Product> getMap() {
		return map;
	}
	
	
	public void setMap(Map<String, Product> map) {
		this.map = map;
	}
	
	@Override
	public String execute() throws Exception {
		for (Entry<String, Product> entry : map.entrySet()) {
			System.out.print(entry.getKey()+"---");
			System.out.print(entry.getValue());
			System.out.println("---------------------");
		}
		return NONE;
	}
}

结果如下:
在这里插入图片描述
分割线没搞好。。。。

2026.2.23:AgentScope框架实战<一>:安装并使用agentscope 本文介绍了AgentScope框架的安装与使用实践。通过PyPI安装agentscope[full]后,演示了如何创建ReActAgent代理:1)配置DashScope聊天模型;2)注册自定义工具函数(查询位置和天气);3)初始化代理并处理用户请求。示例展示了代理如何响应复合查询(如同时获取北京位置和天气信息),输出结果显示代理成功执行了工具调用并返回结构化响应。该框架支持Python 3.13环境,提供内存管理、工具集成等功能,适用于构建智能代理系统。 阅读详情

相关推荐

GEO优化实战:用AnswerBit量化AI搜索可见度与品牌监控体系

生成式引擎优化(GEO)正取代传统SEO,成为品牌在AI搜索生态中获取可见度的关键。当用户习惯从“翻列表”转向“直接问AI”,品牌能否被生成式引擎识别、引用并正向推荐,直接决定了其在用户决策链条中的存在感。AI搜索可见度因此从模糊概念演变为可度量的运营指标,涵盖提及率、引文率、情感分与回源质量等维度。腾讯AnswerBit作为答案侧分析工具,帮助运营者拆解AI回复中的品牌语境与引用来源,让优化动作有据可循。从内容结构化改造、品牌实体建设到第三方权威背书,GEO要求团队建立“度量-优化-再度量”的闭环。文章结

weixin_31100517的博客 151

Servlet的封装

目录封装的必要性我们可以写一个公共类CommonServlet:封装是面向对象的方法应该遵循的一个重要原则!它的英文是encapsulation,有时也叫做数据隐藏。 从形式上看,封装不过是将数据和行为组合在一个包中,并对对象的使用者隐藏了数据的实现形式。 对象中的数据称为实例域(instance field),操纵数据的过程叫做方法(method)对于每个特定的类实例(也就是对象),都有一组特定的实例域值。这些值的集合就是这个对象的当前状态(state).无论何时,只要向对象发送一个消息,它的状态就有

天真吖的博客 869

Power BI应用案例:淘宝用户行为分析实战

一、案例背景 基于千万级的淘宝用户的使用记录,对淘宝用户的行为进行分析,具体指标包括:日PV、日UV、小时PV、小时UV、不同用户行为的PV、用户购买次数分布、用户购买频次分布、活跃用户消费情况等。通过本案例,可以基本看看Power BI都能分析达到怎么样的效果。 二、数据来源及结构 阿里天池官方发布的1万用户在2014年双十二期间的行为记录,数据量达1200万+。 数据下载地址:...

灰哥数据智能的专栏 1万+

Servlet | 连接数据库、使用IDEA工具开发Servlet

Servlet | 连接MySQL数据库、使用IDEA工具开发Servlet

m0_61933976的博客 4838

GNSS数据处理(一)——开源软件RTKLIB与G-Nut/Anubis实战入门

本文详细介绍了GNSS数据处理的开源软件RTKLIB与G-Nut/Anubis的实战入门指南。从软件安装、数据获取到静态短基线解算,逐步讲解操作技巧与常见问题排查,帮助测绘与地质监测人员快速掌握GNSS数据处理技术,提升工作效率。

weixin_30733003的博客 133

SAP公司间STO业务解析(包含主数据解析、后台配置解析、前台业务演示)

SAP公司间STO业务解析

ww114784的博客 1017

开发第一个Servlet&JDBC连接数据库

目录1.开发第一个servlet笔记总结向浏览器响应一段HTML代码2.JDBC连接数据库 文章中用到的环境: java17 Tocat10 mysql-connector-java-8.0.27.jar 1.开发第一个servlet Servlet规范: 第一步: 在webapps下创建一个目录,名为:crm(当然也可以为其他的,例如银行为bank,办公系统为oa等等) 第二步: 在webapp的根下创建一个WEB-INF目录 第三步: 在WEB-INF下创建一个目录:classes 第四步: 在WEB-

向阳-Y.的博客 1400

以宠辱之戒写 SAP Fiori Elements,把标准能力当成身体,把扩展冲动当成大患

SAP Fiori Elements开发中常面临业务方追求"独特页面"的压力,但过度自定义会破坏框架价值。老子"宠辱若惊"的智慧提醒开发者:不应因用户称赞或批评而动摇架构原则。标准模板的价值在于确保业务语义、交互规范和后端服务的一致性。扩展应遵循官方API,将业务逻辑放在ABAP/CDS层而非前端控制器。成熟项目会平衡标准与定制,使用annotation表达UI行为,仅在必要时通过受支持的extension points进行增强,保持系统的长期可维护性。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 999

Servlet通过Druid进行数据库连接

一,先写一个Druid的连接池 public class DruidUtil {     static DruidDataSource dataSource;     static{         Properties properties = new Properties();         try {             properties.load(DruidUtil.clas...

qq_42785997的博客 2199

Transformer时间序列预测-多变量输入-单变量输出+多变量输出,完整代码数据,可直接运行

Transformer时间序列预测-多变量输入-单变量输出+多变量输出,完整代码数据,可直接运行

9794

【异常】Claude Code CLI工具 模型加载异常 /init报错排查与完整解决方案 There‘s an issue with the selected model (glm-5). It

此类跨厂商模型配置报错,核心诱因是API生态的兼容性不匹配。优先使用工具原生支持的模型体系,可快速解决90%以上的同类报错;若需跨厂商使用目标模型,需完成API端点、鉴权密钥、模型ID的全链路适配,确保全流程配置合规,即可完成异常修复。

奶爸的编程之路,也就一周冷个三天 3704

Servlet——数据库连接

JDBC API 取得连接 加载驱动 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 取得连接 Connection con = DriverManager.getConnection("jdbc:odbc:somedb","user","passwd"); JDBC URL表明与1个指定驱动程式方式下的独立数据库。

阿丸笔记 781

EMB电子机械制动系统和EHB电子液压制动系统控制功能的对比

EMB电子机械制动系统相比EHB液压制动系统具有显著优势:响应速度更快(<100ms)、控制精度更高(±2N·m)、能实现单轮独立控制,支持0.1%级制动力调节。在ABS、ESC等安全功能上表现更优,制动平顺性和NVH性能更好,同时提升能量回收效率15%-20%。特别适合智能驾驶需求,可使AEB等系统响应时间缩短50ms,紧急制动距离减少1米以上。EMB系统完美契合高阶自动驾驶对快速响应和精准控制的要求。

m0_59012156的博客 885

Struts2(二)的Servlet的API的访问及数据封装

在使用Struts2的框架的过程中,发现Struts2和Servlet的API是解耦合的。在实际开发中,经常使用到Servlet的API,比如进行登录,将用户的信息保存到Session中,有的时候需要向页面输出一些内容,用到response对象。涉及到Servlet的API的访问。 Struts2的Servlet的API的访问 完全解耦合的方式 使用Servlet的API的原生方式(****...

一只迷失的欢乐·猿的博客 179

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

struts2中action向jsp中传值的方法

先纠正一下,这里不是action传值到jsp页面,而是jsp页面获取action中的属性值,或者范围(如request,session,application等)里的值。所以,有两种方法1,获取的是action属性的值,用struts2标签和ognl即可获取如, <s:property value="属性名.属性名。。。"/> 第二种: 如下1、一般是在Action中定义一个成员变量,然后对这

baidu_36996508的博客 420

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

struts2 页面取值_struts2中action传值到jsp页面的3种方法

先纠正一下,这里不是action传值到jsp页面,而是jsp页面获取action中的属性值,或者范围(如request,session,application等)里的值。所以,有两种方法1,获取的是action属性的值,用struts2标签和ognl即可获取如, 这种形式2,获取的是范围内的值直接使用EL表达式如${name}为requestScope范围绑定的名为name的属性,省略reques...

weixin_39595310的博客 747

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

(二)Struts2--Servlet的API&封装

Struts2–Servlet的API&amp;amp;amp;封装

sage201551的博客 339

Struts2的API的访问以及数据封装

Struts2的servlet的API的访问 在使用Struts2的框架的过程中,发现Struts2和servlet的API是解耦合的。在实际开发中,经常需要使用Servlet的API,比如进行登录,将用户信息保存到session中,向JSP页面输出一些内容,需要用到response对象,都涉及到Servlet的API访问。 1. Struts2的Servlet的API访问方式 1.1.完全解...

xiayubao7788的博客 418

Struts2对Servlet的API的访问,结果页面的配置,数据的封装

Struts2对Servlet的API的访问 1.完全解耦合的方式 通过ActionContext对象,直接获得所有参数的map<String,String[]>,返回参数到页面只能对request,session,application的map进行操作,不能对这些对象本身进行操作。 2.使用ServletAPI的原生方式 ...

Luo_Dong的博客 251

02 Struts2中Servlet的API&Struts2数据封装

写在前面的话: 励志要将JAVA所有的知识点都放在这个号上,不管有没有人看 今天是大年初二,一堆同学聊起了互联网。其实并没有几个人真正能听懂我说的是啥,但是已经很开心了,这个职业越来越被长辈们所认可,以后是信息化社会,不会敲代码,不懂程序设计,那就是原始人。 一、 Struts2的Servlet的API的访问 1、完全解耦合的方式 所谓完全解耦合的方式就是不能获得作用域的对象,不能调用对象的方法,...

一个成长中的程序员,期待用技术的眼光生活 351

struts2的数据封装

文章目录struts2的Servlet的API的访问struts2的结果页面的配置struts2的数据的封装struts2的复杂类型的数据封装 struts2的Servlet的API的访问 struts2的结果页面的配置 struts2的数据的封装 struts2的复杂类型的数据封装 ...

qq_42216575的博客 471

Struts学习笔记(二)使用servlet的API&数据的封装

struts2访问Servlet的API 方式一:完全解耦合-通过ActionContext类访问 ActionContext中保存action执行所需要的一些对象,包括:parameters、request、session、application。下面是ActionContext类访问Servlet API的几个常用方法 使用案例 ////访问servlet的api的方式一:完全解耦合(只能访问map数据,不能获取请求头、ip等 public class RequestDemo1 extends Act

qq_36730954的博客 230

Struts2(二)Struts2的封装方法&其他介绍&注入方式详解

文章目录Struts2的Servlet的API的访问完全解耦合的方式使用Servlet的API的原生方式(*****)接口注入的方式Struts2的结果页面的配置全局结果页面局部结果页面result标签的配置Struts2的数据的封装属性驱动:提供属性set方法的方式(不常用)属性驱动:页面中提供表达式方式模型驱动:采用模型驱动方式(最常用)INPUT的逻辑视图的配置Struts2的复杂类型的数据...

最白の白菜的博客 607

Struts2的API&数据封装(二)

一 Servlet的API的访问 1 完全解耦和的方式 完全看不到request、response、session。 (1)创建jsp界面 <h1>Struts2的servlet的API的访问</h1> <h3>完全解耦和的方式,方式一</h3> <form method="post" action="${pageConte...

weixin_33881753的博客 126

框架 ---Struts2 servlet的API访问 复杂类型的数据封装 结果页面配置 no 02.

在使用Struts2的框架的过程中,发现struts2和servlet的API是解耦的。在实际开发中,经常使用到Servlet的API,比如进行登陆。将用户信息保存大盘session中,有的时候需要向页面输出一下 ...

x.1000001000的博客 263

【Struts】struts访问Servlet API丶数据封装

1. 访问Servlet API1.1 使用ActionContext类获取Servlet API对象对应的Map对象1.2 向Action注入Servlet API对象对应的Map对象1.3 向Action注入原生态Servlet API1.4 使用ServletActionContext类访问Servlet API 1. 访问Servlet API 1.1 使用ActionContext类获取Servlet API对象对应的Map对象 ActionContext ac=ActionContext.g.

Duson 238
上一篇: Struts2(一)--入门及配置详情
下一篇: Struts2(三)--OGNL&值栈
Double____C
博客等级 码龄8年 92粉丝 79原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值