web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list> <filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> </web-app>

  

sqlMapConfig.xml

<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings
cacheModelsEnabled ="true"
lazyLoadingEnabled="true"
enhancementEnabled="true"
errorTracingEnabled="true"
maxRequests="32"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="true"/>
<transactionManager type ="JDBC">
<dataSource type ="JNDI">
<property name ="DataSource" value ="java:comp/env/jdbc/emp" />
</dataSource>
</transactionManager>
<sqlMap resource ="com/struts2/entity/userMap.xml" />
<sqlMap resource ="com/struts2/entity/bookMap.xml" />
</sqlMapConfig >

  

bookMap.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="book"> <typeAlias alias="book" type="com.struts2.entity.Book"/>
<resultMap class="Book" id="bookResultMap">
<result property="bookId"/>
<result property="bname"/>
<result property="bprice"/>
<result property="bcount"/>
<result property="bds"/>
</resultMap> <select id="getBookList" resultMap="bookResultMap">
select bookId,bname,bprice,bcount,bds from(
select e.*,rownum rn from(
select * from Book where 1=1
<isNotNull property="bname" prepend="and">
bname like '%$bname$%'
</isNotNull>
<isNotEmpty property="bprice" prepend="and">
bprice <![CDATA[ <= $bprice$ ]]>
</isNotEmpty>
)e
)
where <![CDATA[ rn>=#startRow# and rn <=#endRow# ]]>
</select> <select id="getTotalCount" resultClass="java.lang.Integer">
select count(*)from Book where 1=1
<isNotNull property="bname" prepend="and">
bname like '%$bname$%'
</isNotNull>
<isNotEmpty property="bprice" prepend="and">
bprice <![CDATA[ <= $bprice$ ]]>
</isNotEmpty> </select> <insert id="addBook" parameterClass="Book">
insert into BOOK(bookId,bname,bprice,bcount,bds)values
(#bookId#,#bname#,#bprice#,#bcount#,#bds#)
</insert> <select id="getBookById" resultMap="bookResultMap">
select * from book where bookId =#bookId#
</select> <update id="updateBook" parameterClass="Book">
update book set bname=#bname#,bprice=#bprice#,bcount=#bcount#,bds=#bds#
where bookId=#bookId#
</update> <delete id="delBook" parameterClass="java.lang.Integer">
delete from book where bookId=#bookId#
</delete> <select id="getBookId" resultClass="java.lang.Integer">
select Seq_id.Nextval from dual
</select>
</sqlMap>

  userMap.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="user"> <typeAlias alias="User" type="com.struts2.entity.User"/>
<parameterMap id="userParameterMap" class="User" >
<parameter property="userid" />
<parameter property="username" />
<parameter property="userpassword" />
<parameter property="role" />
<parameter property="state" />
<parameter property="email" />
<parameter property="createdate" />
</parameterMap>
<resultMap id="userResultMap" class="User">
<result property="userid" column="USERID"/>
<result property="username" column="USERNAME"/>
<result property="userpassword" column="USERPASSWORD"/>
<result property="role" column="ROLE"/>
<result property="state" column="STATE"/>
<result property="email" column="EMAIL"/>
<result property="createdate" column="CREATEDATE"/>
</resultMap>
<select id="getUserByName" resultMap="userResultMap">
select * from User_New where username =#username#
</select>
</sqlMap>

sturt.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>
<constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true"/> <package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index" /> <global-results>
<result name="error">/error.jsp</result>
</global-results> <global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
</package>
<include file="user.xml"></include>
<include file="book.xml"></include>
</struts>

  

  book.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>
<!-- <constant name="struts.enable.DynamicMethodInvocation" value="false" /> -->
<constant name="struts.devMode" value="true"/> <package name="book" namespace="/" extends="struts-default"> <action name="getBookList" class="com.struts2.action.BookAction">
<param name="list">list</param>
<result name="success">/jsp/list.jsp</result>
</action> <action name="addBook" class="com.struts2.action.BookAction"> <result name="success" >/jsp/list.jsp</result>
<result name="addError" >/jsp/error.jsp</result>
</action>
<action name="getbook" class="com.struts2.action.BookAction"> <result name="success" >/jsp/list.jsp</result>
<result name="updateError" >/jsp/error.jsp</result>
<result name="bookObj" >/jsp/updateBook.jsp</result>
</action> <action name="update" class="com.struts2.action.BookAction"> <result name="success" >/jsp/list.jsp</result>
<result name="updateError" >/jsp/error.jsp</result>
<result name="bookObj" >/jsp/updateBook.jsp</result>
</action>
<action name="delbook" class="com.struts2.action.BookAction"> <result name="success" >/jsp/list.jsp</result>
<result name="delError" >/jsp/error.jsp</result> </action> </package>
</struts>

  user.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>
<!-- <constant name="struts.enable.DynamicMethodInvocation" value="false" /> -->
<constant name="struts.devMode" value="true"/> <package name="user" namespace="/" extends="struts-default">
<action name="login" class="com.struts2.action.UserAction">
<result name="success" type="redirectAction">getBookList</result>
<result name="input">/jsp/login.jsp</result>
</action>
</package> </struts>

 

 User.action

package com.struts2.action;

import com.opensymphony.xwork2.Action;
import com.struts2.service.UserService;
import com.struts2.service.impl.UserServiceImpl; public class UserAction implements Action { private String username;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
} UserService service = new UserServiceImpl() ; public String execute() throws Exception { boolean isLogin =service.isLogin(username, password);
if(isLogin){
return SUCCESS;
}else{
return INPUT;
} } }

  Book.acton

package com.struts2.action;

import java.util.ArrayList;
import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.StrutsStatics; import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.struts2.entity.Book;
import com.struts2.service.BookService;
import com.struts2.service.impl.BookServiceImpl; public class BookAction implements Action {
private Book book;
private String flag;
private Integer bookId;
private Integer totalCount;
private Integer totalPage; public Book getBook() {
return book;
} public void setBook(Book book) {
this.book = book;
} public Integer getTotalPage() {
return totalPage;
} public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
} public Integer getTotalCount() {
return totalCount;
} public void setTotalCount(Integer totalCount) {
this.totalCount = totalCount;
} public Integer getBookId() {
return bookId;
} public void setBookId(Integer bookId) {
this.bookId = bookId;
} /* public String getBookId() {
return bookId;
} public void setBookId(String bookId) {
this.bookId = bookId;
}*/ public String getFlag() {
return flag;
} public void setFlag(String flag) {
this.flag = flag;
} public static final int PAGE_SIZE=5; public List<Book> getList() {
return list;
} public void setList(List<Book> list) {
this.list = list;
} private Integer pageIndex; public Integer getPageIndex() {
return pageIndex;
} public void setPageIndex(Integer pageIndex) {
this.pageIndex = pageIndex;
} BookService service = new BookServiceImpl();
List<Book>list = new ArrayList<Book>(); public String execute() throws Exception {
if("2".equals(flag)){ int bookId=service.getBookId();
book.setBookId(bookId);
boolean isAdd=service.addBook(book); book=null; if(!isAdd){
return "addError";
}
}else if("4".equals(flag)){ Book book2=service.getBookById(bookId); HttpServletRequest request=(HttpServletRequest)
ActionContext.getContext().get(StrutsStatics.HTTP_REQUEST);
request.setAttribute("book", book2); return "bookObj";
}else if("5".equals(flag)){
boolean ismodify = service.modifyBook(book);
if(!ismodify){
return "updateError";
}
}else if("3".equals(flag)){
boolean isdel=service.delBook(bookId);
if(!isdel){
return "delError";
}
} if(pageIndex==null){ pageIndex=1;
} totalCount =service.getTotalCount(book);
list = service.getBookList(pageIndex, PAGE_SIZE,book);
totalPage = totalCount%PAGE_SIZE==0 ? (totalCount/PAGE_SIZE) : (totalCount/PAGE_SIZE+1);
return SUCCESS;
} }

  UserDao.java

package com.struts2.dao;

import com.struts2.entity.User;

	public interface UserDao {
public User getUserByName(String username); }

  

  UserDaoImpl.java

package com.struts2.dao.impl;

import java.sql.SQLException;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.struts2.dao.UserDao;
import com.struts2.entity.User;
import com.struts2.util.SqlMapClientUtil; public class UserDaoImpl implements UserDao{
SqlMapClient sqlMapClient = SqlMapClientUtil.getSqlMapClient();
User user=null;
public User getUserByName(String username){
try {
//("user.getUserByName")命名空间 id username
user = (User)sqlMapClient.queryForObject("user.getUserByName", username);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return user;
} }

  BookDao.java

package com.struts2.dao;

import java.util.List;
import com.struts2.entity.Book; public interface BookDao { public List<Book>getBookList(int pageIndex,int pageSize,Book book); public int getTotalCount(Book book); public Book getBookById(int bookId); public Book getBookById(String name); public boolean addBook(Book book); public boolean modifyBook(Book book); public boolean delBook(int bookId); public int getBookId();
}

   BookDaoImpl.java

package com.struts2.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import com.ibatis.sqlmap.client.SqlMapClient;
import com.struts2.dao.BookDao;
import com.struts2.entity.Book;
import com.struts2.util.SqlMapClientUtil; public class BookDaoImpl implements BookDao {
SqlMapClient sqlMapClient =SqlMapClientUtil.getSqlMapClient(); @Override
public List<Book> getBookList(int pageIndex, int pageSize,Book book) {
Map<String,Object> map = new HashMap<String,Object>();
List<Book>list = new ArrayList<Book>(); try {
int startRow=(pageIndex-1)*pageSize+1;
int endRow=pageIndex*pageSize;
map.put("startRow", startRow);
map.put("endRow", endRow);
if(book!=null){
map.put("bname",book.getBname()); map.put("bprice", book.getBprice()); }
list = sqlMapClient.queryForList("book.getBookList", map);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
} @Override
public int getTotalCount(Book book) {
Map<String,Object> map = new HashMap<String,Object>(); int count = 0;
try {
if(book!=null){
map.put("bname",book.getBname());
map.put("bprice", book.getBprice()); }
count =(Integer)sqlMapClient.queryForObject("book.getTotalCount",map);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return count;
} @Override
public Book getBookById(int bookId) { Book book=null;
try {
book = (Book)sqlMapClient.queryForObject("book.getBookById", bookId);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return book;
} public Book getBookById(String name) {
// TODO Auto-generated method stub
return null;
} @Override
public boolean addBook(Book book) {
SqlMapClient sqlMapClient=SqlMapClientUtil.getSqlMapClient();
try {
int count = sqlMapClient.update("book.addBook",book);
if(count>0){
return true;
}else{
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
} @Override
public boolean modifyBook(Book book) { try {
int count = sqlMapClient.update("book.updateBook",book);
if(count>0){
return true;
}else{
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
return false;
} @Override
public boolean delBook(int bookId) {
int count;
try {
count = sqlMapClient.delete("book.delBook", bookId);
if(count>0){
return true;
}else{
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
public int getBookId(){
int bookId=0;
try {
bookId = (Integer)sqlMapClient.queryForObject("book.getBookId");
return bookId;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bookId;
} }

  

  User.java

package com.struts2.entity;

import java.util.Date;

public class User {
private int userid;
private String username;
private String userpassword;
private int role;
private int state;
private String email;
private Date createdate; public User(String username, String userpassword, int role, int state,
String email, Date createdate) {
super();
this.username = username;
this.userpassword = userpassword;
this.role = role;
this.state = state;
this.email = email;
this.createdate = createdate;
}
public User() {
super();
// TODO Auto-generated constructor stub
}
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpassword() {
return userpassword;
}
public void setUserpassword(String userpassword) {
this.userpassword = userpassword;
}
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getCreatedate() {
return createdate;
}
public void setCreatedate(Date createdate) {
this.createdate = createdate;
}
}

  Book.java

package com.struts2.entity;

public class Book {
private int bookId;
private String bname;
private String bprice;
private int bcount;
private String bds; public Book( String bname, String bprice, int bcount, String bds) {
super(); this.bname = bname;
this.bprice = bprice;
this.bcount = bcount;
this.bds = bds;
} public Book() {
super();
// TODO Auto-generated constructor stub
} public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public String getBname() {
return bname;
}
public void setBname(String bname) {
this.bname = bname;
}
public String getBprice() {
return bprice;
}
public void setBprice(String bprice) {
this.bprice = bprice;
}
public int getBcount() {
return bcount;
}
public void setBcount(int bcount) {
this.bcount = bcount;
}
public String getBds() {
return bds;
}
public void setBds(String bds) {
this.bds = bds;
} }

  UserService.java

package com.struts2.service;

public interface UserService {

	public boolean isLogin(String username,String password);

}

  UserServiceImpl.java

package com.struts2.service.impl;

import com.struts2.dao.UserDao;
import com.struts2.dao.impl.UserDaoImpl;
import com.struts2.entity.User;
import com.struts2.service.UserService; public class UserServiceImpl implements UserService { public boolean isLogin(String username, String password) { UserDao userDao = new UserDaoImpl();
User user = userDao.getUserByName(username); if (user != null) { String pwd = user.getUserpassword(); if (pwd.equals(password)) {
return true;
}
return false;
} else {
return false;
}
}
}

  BookService.java

package com.struts2.service;

import java.util.List;
import com.struts2.entity.Book; public interface BookService { public List<Book>getBookList(int pageIndex,int pageSize,Book book); public int getTotalCount(Book book); public Book getBookById(int bookId); public Book getBookById(String name); public boolean addBook(Book book); public boolean modifyBook(Book book); public boolean delBook(int bookId); public int getBookId(); }

   BookServiceImpl.java

package com.struts2.service.impl;

import java.util.List;
import com.struts2.dao.BookDao;
import com.struts2.dao.impl.BookDaoImpl;
import com.struts2.entity.Book;
import com.struts2.service.BookService; public class BookServiceImpl implements BookService {
BookDao dao = new BookDaoImpl();
public List<Book> getBookList(int pageIndex, int pageSize,Book book) {
//
return dao.getBookList(pageIndex, pageSize, book);
} public int getTotalCount(Book book) { return dao.getTotalCount(book);
} public Book getBookById(int bookId) { return dao.getBookById(bookId); } public Book getBookById(String name) {
// TODO Auto-generated method stub
return null;
} public boolean addBook(Book book) { return dao.addBook(book);
} public boolean modifyBook(Book book) {
//
return dao.modifyBook(book);
} public boolean delBook(int bookId) {
//
return dao.delBook(bookId);
} @Override
public int getBookId() {
// TODO Auto-generated method stub
return dao.getBookId();
}
}

  SqlMapClientUtil.java

package com.struts2.util;

import java.io.IOException;
import java.io.Reader;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder; public class SqlMapClientUtil {
public static SqlMapClient getSqlMapClient() {
SqlMapClient sqlMapClient = null;
Reader reader = null; try {
reader = Resources.getResourceAsReader("sqlMapConfig.xml");
sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return sqlMapClient; }
}

  

JAVAWEB 一一 Sturts2+ibatis(框架,Sturts2,用action代替servlet)的更多相关文章

  1. JAVAWEB 一一 Spirng(框架,IOC控制反转,DI依赖注入)

    jar包 applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <bea ...

  2. JAVAWEB 一一 Hibernate(框架)

    实体类关联数据库字段,操作实体类,HQL语句对数据结构CRUD) 引入jar包 配置文件 hibernate.cfg.xml User.hbm.xml <?xml version="1 ...

  3. iBatis框架batch处理优化 (转)

    为什么要做batch处理        这个问题我就不解释了,因为我想你们肯定能比我解释的更好!如果你真的不知道,那就到Google上去搜索一下吧☻Oracle回滚段    这个问题偶也不很明白,只是 ...

  4. spring+struts2+ibatis 框架整合以及解析

    一. spring+struts2+ibatis 框架 搭建教程 参考:http://biancheng.dnbcw.net/linux/394565.html 二.分层 1.dao: 数据访问层(增 ...

  5. iBatis框架基本使用

    iBatis框架是Java持久层开发框架,说白了就是前人写了一部分代码(针对数据库操作),我们要做的就是再次开发,拿来框架直接使用. 我们自己开发时,dao层的sql语句都是写死在程序中的,如果查询条 ...

  6. iBatis框架简介

    一.为啥使用iBatis? 在 Hibernate.JPA 这样的一站式对象 / 关系映射(O/R Mapping)解决方案盛行之前,iBaits 基本是持久层框架的不二选择.即使在持久层框架层出不穷 ...

  7. 【转】深入分析 iBATIS 框架之系统架构与映射原理

    深入分析 iBATIS 框架之系统架构与映射原理 iBATIS 通过 SQL Map 将 Java 对象映射成 SQL 语句和将结果集再转化成 Java 对象,与其他 ORM 框架相比,既解决了 Ja ...

  8. 深入分析 iBATIS 框架之系统架构与映射原理--转载

    http://www.ibm.com/developerworks/cn/java/j-lo-ibatis-principle/ iBATIS 通过 SQL Map 将 Java 对象映射成 SQL ...

  9. Struts2框架学习(二) Action

    Struts2框架学习(二) Action Struts2框架中的Action类是一个单独的javabean对象.不像Struts1中还要去继承HttpServlet,耦合度减小了. 1,流程 拦截器 ...

  10. spring struts2 ibatis 框架结构图

    spring struts2 ibatis 框架结构图

随机推荐

  1. CentOS7.4安装部署openstack [Liberty版] (二)

    继上一篇博客CentOS7.4安装部署openstack [Liberty版] (一),本篇继续讲述后续部分的内容 一.添加块设备存储服务 1.服务简述: OpenStack块存储服务为实例提供块存储 ...

  2. 匿名内部类中不能修改int变量时、final int i 不能改变i的值时、或 i++线程不安全。使用AtomicInteger;

    在匿名内部类或某某情况下中引入的变量必须是Final最终型的:这时还想要去修改这个变量就需要使用到AtomicInteger这个类了: AtomicInteger CarSize = new Atom ...

  3. ScrollView嵌套RecyclerView、ScrollView嵌套Listview、ScrollView嵌套各种布局,默认不在顶部和回到顶部的解决方法;

    如果: ScrollView.scrollTo(0,0): ScrollView.fullScroll(View.FOCUS_UP) : ScrollView.smoothScrollTo(0, 0) ...

  4. ECharts学习记录

    一.ECharts在GitHub的地址以及需要引入文件地址: 1.Github地址:https://github.com/ecomfe/echarts 2.官网下载文件地址:http://echart ...

  5. ubantu 上hadoop 搭建

    Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04 参考 http://www.powerxing.com/install-hadoop/ 2014-08-09 ...

  6. sql语句基础(一)

    数据库基本操作  创建数据库  CREATE DATABASE database-nam 2.  删除数据库 drop database dbname 3. 备份sql server --- 创建 备 ...

  7. Heap Dump (heap=dump)

    Heap Dump (heap=dump) 转储堆内容使用heap=dump选项.可以是ASCII或者是二进制格式,根据设定的格式,jhat解析二进制格式.format=b. 如果指定格式是二进制,转 ...

  8. spring 之 lookup-method & replace-method

    初始化bean的堆栈: at org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy$Cglib ...

  9. Flex学习笔记-皮肤

    1文件结构 MXML应用程序 index.mxml 皮肤文件 components.button.skin.btnSkin1.mxml  皮肤文件的组件随便引用了spark.components.Bu ...

  10. Jquery的一些基本操作

    /*获得TEXT.AREATEXT的值*/ var textval = $("#text_id").attr("value"); //或者 var textva ...