利用struts2连接数据库框架建立的购票系统,怎样让从数据库中传过来的所有商品表,table只显示某一类票

Struts2+Spring+Ibatis框架里 &s:select&标签中如何显示数据库中的内容_百度知道
Struts2+Spring+Ibatis框架里 &s:select&标签中如何显示数据库中的内容
name=&s,我们的课件上 是这样写的&roleid&&roleList& listKey=&user.roleId&name& list=&roleList&我感觉这个list=&id&quot:select id=&/ 一定是数据库中的某表中的某个字段 但是课件不全 只是写了这么句话我觉得应该可以; listValue=&quot
提问者采纳
s。如name属性。换句话说,也就是你想在下拉列表中显示的内容。listKey理解&lt。如id属性。listValue。list属性,指你的下拉列表显示给用户的内容,你的roleList是在action里定义的一个集合:select&标签里面各个属性的含义你就明白了,指你的下拉列表实际提交的内容。id和name我就不解释了,而这个集合里的数据是从数据库里查询出来的,并不是指你数据库表中的字段
抱歉我忘记设置问题分数了 一会我会追加给您 ,公司里禁止通讯工具 我再问你两个问题哈谢谢,你的意思是我进到这个页面前先进ACTION里然后从数据库中取数据放到这个roleList中然后return到这个JSP页面就能自动获取么?假设ACTION中 roleList已经有了数据,需要写哪些代码可以让JSP获取到这个roleLIst?
因为你用的struts2,所以有个前提:roleList是你action里的一个字段,并且必须要有getter和setter,满足这个条件的话,其他代码不用了,直接使用你第一次贴的代码就可以实现了。
提问者评价
你那正直无私的精神在这个黑暗的社会里显得是那么的闪耀。。能加个你的QQ么,我的 赐教。。
其他类似问题
为您推荐:
ibatis的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&运用struts2中的ognl表达式调用类方法(转)_运用Struts2实现分页显示_运用struts2由树形数据结构生成table__脚本百事通
稍等,加载中……
^_^请注意,有可能下面的2篇文章才是您想要的内容:
运用struts2中的ognl表达式调用类方法(转)
运用Struts2实现分页显示
运用struts2由树形数据结构生成table
运用struts2中的ognl表达式调用类方法(转)
使用struts2中的ognl表达式调用类方法(转)
使用&s:debug/&可以看一下这个调试页,然后决定用#或$吧。Struts2还提供了一些命名对象,这些命名对象与根对象无关,它们只是存在于Stack Context中。所以,访问这些对象时需要使用#前缀来指明。1.parameters对象:用于访问HTTP请求参数。例如#parameters['foo']或#parameters.foo,用于返回调用HttpServletRequest的getParameter("foo")方法的返回值。2.request对象:用于访问HttpServletRequest的属性。例如# request ['foo']或# request.foo,用于返回调用HttpServletRequest的getAttribute("foo")方法的返回值。3.session对象:用于访问HttpSession的属性。例如# session ['foo']或# session.foo,用于返回调用HttpSession的getAttribute("foo")方法的返回值。4.application对象:用于访问ServletContext的属性。例如# application ['foo']或# application.foo,用于返回调用ervletContext的getAttribute("foo")方法的返回值。5.attr对象:该对象将依次搜索如下对象:PageContext、HttpServletRequest、HttpSession、ServletContext中的属性。注意:当系统创建了Action实例后,该Action实例已经被保存到ValueStack中,故无需书写#即可访问Action属性。
提供多一种访问静态方法和变量的方式.@className@variableName@className@methodName()如:&s:property value="@java.lang.Math@random()"/&@examples.chap8.Muppet@OG_MUPPET@examples.chap8.Muppet@getOgMuppet()
在数据库的设计中,字典项是经常使用的技巧。比如在一个图书馆系统中,书籍表(Book)会有一个分类字段,这时候我们一般会单独建立一张分类表(Category),在书籍表只保存分类表的ID。在用户界面上显示书籍明细的时候,会要求显示CategoryID在Category表中对应的名称。这样通常的做法是把Book和Category两张表进行关联。但在实际应用中,Category一般都是Cache在应用服务器端,再使用数据表的连接就不够高效。我的做法是这样的:在iBatis中使用SqlMap从表中将数据取出,此时不使用数据表的连接。
package com.public class Book {
private int
private int categoryId;
private S}
package com.public class Category {
private static Map&Integer, Category& cacheM
private int
public static Category getCategory(int id) {
return cacheMap.get(id);
public static Map&Integer, Category& getCategoryMap() {
return cacheMap();
private init() {
if ( cacheMap != null ) return;
// the code to load category from datebase
// 在这里为了演示的需要,使用以下代码
cacheMap = new HashMap&Integer, Category&();
Category category = new Category();
category.setId(1);
category.setName("Fiction");
cacheMap.put(1, category);
category = new Category();
category.setId(2);
category.setName("Cartoon");
package com.public class BookAction
public String execute() {
book = new Book();
book.setId(1);
book.setName("Thinking in java");
book.setCategoryId(1);
bookList.add(book);
return SUCCESS;
&%@ taglib prefix="s" uri="/struts-tags"%&&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&&html& &head&
&s:head /& &/head& &body&
&table border="1"&
&s:text name="page.label.userName" /&
&s:property value="book.name" /&
&s:text name="page.label.category" /&
&s:property value="@com.demo.Category@getCategory(book.categoryId).getName()"/&&/td&
&/tr& &/body&&/html&
运用Struts2实现分页显示
使用Struts2实现分页显示在开发web程序时,从数据库中取出来的数据一般都要分页显示在页面上,分页显示的方法非常多,有人写自定义标签,用自己写的标签进行分页显示,我个人觉得这是一种比较好的方法。下面是我用Struts2做的一个分页显示实例,基本的思路是:把数据库表中的每一行数据封装成一个对象,用一个返回类型为List的方法返回这些对象,接着在Struts2的action里面定义一个List属性,用这个List来接收从数据库中查询出来并进行了封装的那些对象,然后通过Struts2的标签遍历List里的每个对象,并把这些对象里所包含的属性取出来展现在页面上。
下面是具体的步骤:
所用工具:JDK1.6 + MyEclipse6.0 + Tomcat6.0 + MySQL5.0 + struts 2.0.11
1、新建一个web工程,导入struts2中相应的jar包和mysql数据库驱动包。
2、编写web.xml文件,其代码如下:
&?xml version="1.0" encoding="UTF-8"?&
&web-app version="2.4" xmlns="/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="/xml/ns/j2ee
/xml/ns/j2ee/web-app_2_4.xsd"&
&filter-name&struts2&/filter-name&
&filter-class&
org.apache.struts2.dispatcher.FilterDispatcher
&/filter-class&
&filter-mapping&
&filter-name&struts2&/filter-name&
&url-pattern&/*&/url-pattern&
&/filter-mapping&
&welcome-file-list&
&welcome-file&index.jsp&/welcome-file&
&/welcome-file-list&
&/web-app&
3、建一个数据库表,用于保存学员信息:
create table student (
stu_id integer auto_increment,
stuName varchar(30) not null,
address varchar(50) not null,
stuPhone varchar(15)not null,
primary key(stu_id)
insert into student(stuName,address,stuPhone) values('杨华林','长沙','');
insert into student(stuName,address,stuPhone) values('李明清','天津','');
insert into student(stuName,address,stuPhone) values('李小华','大连','');
insert into student(stuName,address,stuPhone) values('郑小明','苏州','');
insert into student(stuName,address,stuPhone) values('杨一新','西安','');
insert into student(stuName,address,stuPhone) values('王新任','广州','');
insert into student(stuName,address,stuPhone) values('谢小华','深圳','');
insert into student(stuName,address,stuPhone) values('王建明','厦门','');
insert into student(stuName,address,stuPhone) values('秦一生','北京','');
insert into student(stuName,address,stuPhone) values('田翠林','杭州','');
insert into student(stuName,address,stuPhone) values('陈小明','广州','');
4、编写PageDAO类,该类用于从数据库中取出所有的学员信息,把这些学员信息封装成一个Student对象并将其放入List中。
package org.hnylj.
import java.sql.C
import java.sql.DriverM
import java.sql.PreparedS
import java.sql.ResultS
import java.sql.SQLE
import java.util.ArrayL
import java.util.L
public class PageDAO {
private PreparedS
private ResultS
private static final String DRIVER = "com.mysql.jdbc.Driver" ;
private static final String URL = "jdbc:mysql://localhost:3306/page" ;
private static final String USERNAME = "root" ;
private static final String PASSWORD = "123" ;
//数据库连接
public synchronized Connection getConnection () {
Class.forName (DRIVER) ;
conn = DriverManager.getConnection (URL,USERNAME,PASSWORD) ;
} catch (ClassNotFoundException e) {
e.printStackTrace () ;
} catch (SQLException e) {
e.printStackTrace () ;
//分页查询
public List&Student& queryByPage (int pageSize, int pageNow) {
List&Student& list = new ArrayList&Student& () ;
if (this.getConnection()!=null && pageSize&0 && pageNow&0) {
pstmt = this.getConnection().prepareStatement(
"select * from student order by stu_id limit "+(pageNow*pageSize-pageSize)+","+pageSize
rs = pstmt.executeQuery () ;
while (rs.next()) {
student = new Student () ;
student.setStu_id (rs.getInt(1)) ;
student.setStuName (rs.getString(2)) ;
student.setAddress (rs.getString(3)) ;
student.setStuPhone (rs.getString(4)) ;
list.add (student) ;
} catch(SQLException e) {
e.printStackTrace() ;
5、由于要对数据库中的学员信息进行封装,所以需要编写一个JavaBean,即Student类:
package org.hnylj.
public class Student {
private int stu_
private String stuN
private String stuP
public Student () {
public int getStu_id () {
return stu_
public void setStu_id (int stu_id) {
this.stu_id = stu_
public String getStuName () {
return stuN
public void setStuName (String stuName) {
this.stuName = stuN
public String getAddress () {
public void setAddress (String address) {
this.address =
public String getStuPhone () {
return stuP
public void setStuPhone (String stuPhone) {
this.stuPhone = stuP
至此底层的代码就写好了。接下来我们需要编写web层的代码。
6、编写web层的jsp文件,分别有index.jsp,show.jsp和error.jsp,其代码分别如下:
&%@ page language="java" pageEncoding="UTF-8"%&
&%@ taglib uri="/struts-tags" prefix="s"%&
&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&
&title&Struts2实现分页显示&/title&
&div align="center"&
&s:a href="show.action"&进入查看学员列表&/s:a&
&%@ page language="java" pageEncoding="UTF-8"%&
&%@ taglib uri="/struts-tags" prefix="s"%&
&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&
&title&Struts2实现分页显示&/title&
&div align="center"&
&table border="1"&
&th&学号&/th&
&th&姓名&/th&
&th&地址&/th&
&th&电话&/th&
&s:iterator value="students"&
&td&&s:property value="stu_id"/&&/td&
&td&&s:property value="stuName"/&&/td&
&td&&s:property value="address"/&&/td&
&td&&s:property value="stuPhone"/&&/td&
&/s:iterator&
&s:url id="url_pre" value="show.action"&
&s:param name="pageNow" value="pageNow-1"&&/s:param&
&s:url id="url_next" value="show.action"&
&s:param name="pageNow" value="pageNow+1"&&/s:param&
&s:a href="%{url_pre}"&上一页&/s:a&
&s:iterator value="students" status="status"&
&s:url id="url" value="show.action"&
&s:param name="pageNow" value="pageNow"/&
&/s:iterator&
&s:a href="%{url_next}"&下一页&/s:a&
&%@ page language="java" pageEncoding="UTF-8"%&
&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&
&title&发生错误&/title&
业务逻辑发生异常,请稍候再试。。。。。。
7、编写struts2的action来拦截用户的请求:
package org.hnylj.
import java.util.L
import org.hnylj.util.PageDAO;
import org.hnylj.util.S
import com.opensymphony.xwork2.ActionS
public class ShowAction extends ActionSupport {
private List&Student&
private int pageNow = 1 ; //初始化为1,默认从第一页开始显示
private int pageSize = 5 ; //每页显示5条记录
private PageDAO pageDAO = new PageDAO () ;
public List&Student& getStudents() {
public void setStudents(List&Student& students) {
this.students =
public int getPageNow() {
return pageN
public void setPageNow(int pageNow) {
this.pageNow = pageN
public int getPageSize() {
return pageS
public void setPageSize(int pageSize) {
this.pageSize = pageS
public String execute() throws Exception {
students = pageDAO.queryByPage(pageSize, pageNow) ;
return SUCCESS ;
8、配置struts.xml文件,即action和响应结果页面之间的映射:
&?xml version="1.0" encoding="UTF-8" ?&
&!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"&
&package name="struts2" namespace="/" extends="struts-default"&
&action name="show" class="org.hnylj.web.ShowAction"&
&result name="success"&show.jsp&/result&
&result name="error"&error.jsp&/result&
&/package&
至此所有的工作已经完成,接下来部署整个web工程到tomcat的webapps目录下,启动tomcat,在浏览器地址栏输入http://localhost:8080/项目名称/index.jsp,回车即可看到一个链接,点击该链接即可看到一个可以进行上一页和下一页的学员信息列表。
该应用有一些不足之处,因为我也是刚学struts2不久,打算以后有时间再完善一下,对于struts2大家是怎么分页的,希望能提供好的建议,一起学习,共同进步!
hellolaojiang:对数据库中的每一个行都封装成对象后呈现,会不会有性能的问题?
谢谢你提出的问题,在这个示例中我没有作性能方面的考虑,你的提问让我有新的思考!
你的PageDAO 耦合Student类如果业务里除了学生分页,还要学科分页 老师分页,难道要做Page2Dao Page3Dao?
如果业务里除了学生分页,还要学科分页,老师分页等,做法就是在PageDao里面另写一个查询方法,如:public List&Student& queryTeacherByPage (int pageSize, int pageNow),有几个需要分页的就写几个方法。当然最好的做法是把这个查询方法写成通用的,如:public List&Student& queryByPage (int pageSize, int pageNow,String sql)写成这样就可以做到根据不同的sql语句查出不同的数据。
&s:url id="url_pre" value="show.action"&
页面上这样的连接也和具体的action类绑定的了,如果是针对每个对象都有一个action,例如老师和学生都有一个action,那么你这样的做法就有些问题。如果把所有的老师学生等等都写到showAction里,岂不是有一个“万能类”出现了。。。。我最近也碰到很多分页的麻烦。郁闷啊~~~
运用struts2由树形数据结构生成table
应用struts2由树形数据结构生成table
一:创建数据库:
create database InterViewTest1
use InterViewTeat1;
create table Category
id int(10) auto_increment,
name varchar(50),
code varchar(50),
parentCode varchar(50),
serNum int,--排序号
primary key(id)
)ENGINE=INNODB DEFAULT CHARSET=
关于示例数据请看附件的sql文件二:核心算法
本算法主要是利用递归实现把树形结构的每条从根节点到叶子节点的路径放到一个二维String数组中,当有些路径的元素个数不能达到最大深度的时候,此路径元素个数与最多元素个数相差num,那么这个位置就用c_num填补。
private String rootN
//树的深度
//树的叶子个数
private String[][] array=
private CategoryService cs=
public CategoryOp(String rootName){
this.rootName=rootN
private void getAllNode(List&String& list,Category[] c){
if(c!=null){
for(int i=0;i&c.i++){
list.add(c[i].getName());
if(c[i].getChildCategory().length!=0){
getAllNode(list,c[i].getChildCategory());
for(String str:list){
array[this.width][k]=
for(int j=k;j&this.j++){
array[this.width][j] ="c_"+ (this.height+1-k);
this.width++;
list.remove(list.size()-1);
private void getNum(List&String& list,Category[] c){
if(c!=null){
for(int i=0;i&c.i++){
list.add(c[i].getName());
if(c[i].getChildCategory().length!=0){
getNum(list,c[i].getChildCategory());
if(this.height&list.size()){
this.height=list.size();
this.width++;
list.remove(list.size()-1);
public String getWidthAndHeight(){
cs=new CategoryService(this.rootName);
Category[] category=cs.getAllCategory();
this.width=0;
this.height=0;
List&String& list=new ArrayList&String&();
this.getNum(list, category);
return this.height+","+this.
public String[][] initArray(){
this.array=
this.width=0;
this.height=0;
this.getWidthAndHeight();
array=new String[this.width][this.height];
cs = new CategoryService(this.rootName);
Category[] c = cs.getAllCategory();
// this.height = 0;
this.width = 0;
List&String& list = new ArrayList&String&();
this.getAllNode(list, c);
public String getTable(){
this.initArray();
int w=this.
int h=this.
int num=0;
for(int i=0;i&w;i++){//这是为了合并表头
for(int j=0;j&h;j++){
if(array[i][j].startsWith("c_")){
String temp=array[i][j].substring(2);
if(this.isNumeric(temp)!=-1&&this.isNumeric(temp)&num){
num=this.isNumeric(temp);
StringBuilder sb=new StringBuilder();
sb.append("&table id=\"data\" border=\"1\" style=\"float\"&");
sb.append("&tr&");
sb.append("&td align=\"center\"&项目&/td&");
sb.append("&td colspan=\""+num+1+"\" align=\"center\"&科目&/td&");
sb.append("&/tr&");
for(int i=0;i&w;i++){
sb.append("&tr&");
for(int j=0;j&h;j++){
if (j & h - 1 && array[i][j + 1].startsWith("c_"))
String tmp = array[i][j + 1].substring(2);
sb.append("&td align='center' colspan='" + (this.isNumeric(tmp) + 1) + "'&" + array[i][j] + "&/td&");
sb.append("&td align='center' &" + array[i][j] + "&/td&");
sb.append("&/tr&");
sb.append("&/table&");
return sb.toString();
三:应用jquery实现每列相同文本的单元格合并:
function _w_table_lefttitle_rowspan(_w_table_id,_w_table_mincolnum,_w_table_maxcolnum){
if(_w_table_mincolnum == void 0){_w_table_mincolnum=1;}
if(_w_table_maxcolnum == void 0){_w_table_maxcolnum=_w_table_}
if(_w_table_mincolnum&_w_table_maxcolnum){
return "";
var _w_table_splitrow=new Array();
for(iLoop=_w_table_iLoop&=_w_table_iLoop++){
_w_table_onerowspan(iLoop);
function _w_table_onerowspan(_w_table_colnum){
_w_table_firstrow = 0;//前一列合并区块第一行
_w_table_SpanNum = 0;//合并单元格时的,单元格Span个数
_w_table_splitNum = 0;//数组的_w_table_splitrow的当前元素下标
_w_table_Obj = $(_w_table_id + " tr td:nth-child(" + _w_table_colnum + ")");
_w_table_curcol_rownum = _w_table_Obj.length-1;//此列最后一行行数
if(_w_table_splitrow.length==0){_w_table_splitrow[0] = _w_table_curcol_}
_w_table_lastrow = _w_table_splitrow[0];//前一列合并区块最后一行
var _w_table_
var _w_table_
var _w_table_curcol_splitrow=new Array();
_w_table_Obj.each(function(i){
if(i==_w_table_firstrow){
_w_table_firsttd = $(this);
_w_table_SpanNum = 1;
_w_table_currenttd = $(this);
if(_w_table_firsttd.text()==_w_table_currenttd.text()){
_w_table_SpanNum++;
_w_table_currenttd.hide(); //remove();
_w_table_firsttd.attr("rowSpan",_w_table_SpanNum);
_w_table_firsttd = $(this);
_w_table_SpanNum = 1;
setTableRow(i-1);
if(i==_w_table_lastrow){setTableRow(i);}
function setTableRow(_splitrownum){
if(_w_table_lastrow&=_splitrownum&&_w_table_splitNum++&_w_table_splitrow.length){
//_w_table_firstrow=_w_table_lastrow+1;
_w_table_lastrow=_w_table_splitrow[_w_table_splitNum];
_w_table_curcol_splitrow[_w_table_curcol_splitrow.length]=_
if(i&_w_table_curcol_rownum){_w_table_firstrow=_splitrownum+1;}
_w_table_splitrow=_w_table_curcol_
三:为了增加适用性,我用了jquery的ajax效果
function btnCreate(){
$("#ajax").html("&img src=\"images/spinner3-greenie.gif\"/&");
type:"post",
url:"create.action",
complete:function(){},
success:function(data){
$("#ajax").html(data);
_w_table_lefttitle_rowspan("#data",1,90);
四:显示效果:
数据库数据存储:
jquery等待:
生成表格示例:
如果您想提高自己的技术水平,欢迎加入本站官方1号QQ群:&&,&&2号QQ群:,在群里结识技术精英和交流技术^_^
本站联系邮箱:Struts2+Hibernate架构技术教程课后参考答案_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
Struts2+Hibernate架构技术教程课后参考答案
上传于||暂无简介
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
下载文档到电脑,查找使用更方便
还剩5页未读,继续阅读
你可能喜欢SSH2框架图片上传到数据库并显示在JSP页面_百度知道
SSH2框架图片上传到数据库并显示在JSP页面
SSH2框架图片上传到数据库并显示在JSP页面 这个搞不懂 我想知道action里面和daoimpl里面怎么写 后台咋么写 大哥 帮帮忙
能不能给我个参考 头痛阿
提问者采纳
&&&&&nbsp.close();String&&length&&&&&&&&List&lt.get(i));+distF&&fileContentT&&&&nbsp,也可以用代码创建;&&&&&&FileInputStream(=&&&List&=&fileContentType)&String&&&&&&&&ServletActionC&&&&&=&&&nbsp,直接提取出来用IMG标签装载即可&String&=&&new&&}public&&&&&/upload&&s&&&&&&&&&&&&&&&&&&&&&fileFileN&&List&&&is&&name=“file”的文件将会被装进去;fileFileN&&&private&nbsp.getFileFileName();new&nbsp、String&private&&&List&&&&nbsp,length);File&&&&nbsp,&fileFileName)&i&&&&&&&&&&&&&&&newFilePath&String&&&&&&&byte[400];&=&}//dao的代码不需要很复杂;File(&nbsp.write(&&fileFileN&&;&&&&&=&&&&{&throws&&&&&List&&gt.file&&&while((length&&&&nbsp.read(buffer))&&&//在webroot先建立个upload文件夹;&Exception&&{&&&nbsp.size()&&&String&&return&&&&fileContentT&&&&&&}public&&&&&&InputStream&&&distFile&&{&&&&&&&&fileContentTFile&&&&nbsp.getRealPath(&&0&String&&i++){&&&String&&nbsp,如果只上传一//个文件可以直接声明成;&=&&&&os&&&new&&&=&//数据库存放以下路径;&&getFileContentType()&&&String&nbsp,页面提交过来的n个input&String&&&&&&nbsp.getFileName();&&setFile(List&new&&&nbsp,当需要在页面显示;&&OutputStream&&nbsp.fileFileName&=&byte[]&setFileContentType(List&&&&&;&&&&file)&void&List&String&{&&&&&=&&&&0;&}&&&}public&&&{&&&&&nbsp://这里使用集合;&&&&&&&getFileFileName()&&&&&&&&&&nbsp.get(i));&&File&&nbsp,就直接使用了&&&&&&&nbsp.getRequest();os.close();FileOutputStream(distFile);&&&&&}public&&&void&buffer&=&&&&&void&&/&&int&&&&&&&&&&&setFileFileName(List&0){&&fileFileN=&&&new&&&&}public&&{&&execute()&&&&();&&&nbsp:private&&nbsp,0;&&File&String&&&fileContentTypeprivate&&&&&public&&&&root+&List&&ArrayList&&&&SUCCESS;&&&&getFile()&&i&&&&&return&{&}public&&&&nbsp、String&);&&&&&return&&&&&&&nbsp//传统的struts2上传是很简单的;&&&&&&nbsp,简单的执行数据库插入就好.fileContentType&&&&File&&return&&for(int&&&&=&&&root&&&}&nbsp,这里为了简便;&nbsp。//页面form提交到action
提问者评价
dao 插入就是save自己带的?
来自:求助得到的回答
其他类似问题
为您推荐:
jsp的相关知识
其他1条回答
你把上传的图片的路径保存在数据库中,用一个字段保存,显示图片的时候,查询表把这个路径查出来就可以显示了啊 这个还是忙容易的
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 struts2连接数据库 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信