property value="ncontent"/>取出即可
使用模型驱动:
查改
新建action查询文章类型:
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.txxw.cms.news.model.Ctype;
import com.txxw.cms.news.model.CtypeService;
/**
* @author fejd E-mail:
lzd_niit_java@
* @version 创建时间:
May 22, 2009 1:
43:
21 PM
* 功能实现:
文章类型修改内容查询
*/
public class CtypeeditAction extends ActionSupport implements ModelDriven{
private Ctype ctype=new Ctype();//将封装数据的ctype实现get和set方法
@Override
public Stringexecute() throws Exception{
// TODO Auto-generatedmethodstub]
HttpServletRequestrequest=ServletActionContext.getRequest();
int ct_id=Integer.parseInt(request.getParameter("ct_id").replace(",", ""));//通过选择复选框来实现单个文章类型修改
CtypeServicecs=new CtypeService();
Ctypectype=cs.editctypesql(ct_id);
this.setCtype(ctype);
return "success";
}
public ObjectgetModel(){
// TODO Auto-generatedmethodstub
return null;
}
public CtypegetCtype(){
return ctype;
public void setCtype(Ctypectype){
this.ctype =ctype;
}
}
Editctypesql()方法如下:
public Ctype editctypesql(int ct_id) throws IOException{
dbcon=new DBConnection();
con=dbcon.getCon();
Ctypecty=null;
Listctylist=new ArrayList();
try {
psta=con.prepareStatement(this.getEditCtypesql(ct_id));
psta.setInt(1,ct_id);
rs=psta.executeQuery();
while(rs.next())
{
cty=new Ctype();
cty.setCt_id(rs.getInt("ct_id"));
cty.setCt_name(rs.getString("ct_name"));
cty.setCt_sid(rs.getString("ct_sid"));
//数据类型Clob转换String类型START//
try
{
oracle.sql.CLOBclob=(oracle.sql.CLOB)rs.getClob("ct_introduction");//数据库中存文本的CLOB型字段名
Stringct_introduction=clob.getSubString((long)1,(int)clob.length());//subString是截取字符串(从1截到length)
if(clob==null||ct_introduction==null||ct_introduction==""){
return null;
}
cty.setCt_introduction(ct_introduction);
System.out.println(ct_introduction);
}//try
catch(Exceptione){
logger.debug("数据类型Clob转换String类型出现异常");
logger.info("数据类型Clob转换String类型出现异常");
e.printStackTrace();
}
//数据类型Clob转换String类型END//
cty.setCt_image(rs.getString("ct_image"));
ctylist.add(cty);
}
} catch (SQLExceptione){
// TODO Auto-generatedcatchblock
e.printStackTrace();
}
return cty;
}
public StringgetEditCtypesql(int ct_id){
this.editCtypesql="select*fromsystem.ctypewherect_id=?
";
return editCtypesql;
}
public void setEditCtypesql(StringeditCtypesql){
this.editCtypesql =editCtypesql;
}
注明:
上述方法中涉及到Oracle数据类型Clob转换成String类型问题
在jsp中使用
property value="ctype.ct_id"/>
即可取出ctype中的数据。
13、js“返回上一页”
p