public void setCtype(Ctype ctype) {
this.ctype = ctype;
}
}
Editctypesql()方法如下:
public Ctype editctypesql(int ct_id) throws IOException{
dbcon=new DBConnection();
con=dbcon.getCon();
Ctype cty=null;
List ctylist=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.CLOB clob=(oracle.sql.CLOB)rs.getClob("ct_introduction");//数据库中存文本的CLOB型字段名
String ct_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(Exception e){
logger.debug("数据类型Clob转换String类型出现异常");
logger.info("数据类型Clob转换String类型出现异常");
e.printStackTrace();
}
//数据类型Clob转换String类型END//
cty.setCt_image(rs.getString("ct_image"));
ctylist.add(cty);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return cty;
}
public String getEditCtypesql(int ct_id) {
this.editCtypesql="select *from system.ctype where ct_id=?";
return editCtypesql;
}
public void setEditCtypesql(String editCtypesql) {
this.editCtypesql = editCtypesql;
}
注明:上述方法中涉及到Oracle数据类型Clob转换成String类型问题
在jsp中使用
<s:property value="ctype.ct_id"/>
即可取出ctype中的数据。
13、js“返回上一页”
<a style="cursor:pointer" href="javascript:history.go(-1);">返回上一页</a>
或者:
<a style="cursor:pointer" onclick="javascript:history.back(0);">向上</a>
14、Strust2 判断标签<s:if></s:if><s:else if></s:else:if>
<s:if test="display==1||auditing==1">
<font color="red"><s:property value="ntitle" /></font>
</s:if>
<s:elseif test="display==0||auditing==0">
<font color="blue"><s:property value="ntitle" /></font>
</s:elseif>
15、Struts2+ajax实现批量删除,批量更新操作
全选: checkAll()
不选: checkAllNo()
反选: swichAll()
批量删除: deletenews()
批量更新:display1news()
<script type="text/javascript">
function checkAll(){
var obj=document.getElementsByName("nid");
for(i=0;i<obj.length;i++){
obj[i].checked=true;
}
}
function checkAllNo(){
var obj=document.getElementsByName("nid");
for(i=0;i<obj.length;i++){
obj[i].checked=false;
}
}
function switchAll(){
var obj=document.getElementsByName("nid");
for(i=0;i<obj.length;i++){
obj[i].checked =! obj[i].checked;
}
}
function vals(input1,input2)
{
var temp="";
var objForm = document.forms[input1];
var objLen = objForm.length;
for (var iCount = 0; iCount < objLen; iCount++)
{
if (objForm.elements[iCount].type == "checkbox")
{
if(objForm.elements[iCount].checked==true&&objForm.elements[iCount].nid!="allSelected"&&objForm.elements[iCount].nid!="allConcled")
{
temp=temp+objForm.elements[iCount].value+",";
}
// objForm.elements[iCount].checked = true;
}
}
return temp;
}
有待补充\(^o^)/.
如果文章中有瑕疵,欢迎各位提出并修改;技术王国,共同进步。O(∩_∩)O~