jsp页面中用sql语句怎样添加一条记录
展开全部
建议使用bean:
<jsp:useBean id="sel" class="tst.updateBean" scope="session">
</jsp:useBean>
<jsp:setProperty property="database" name="sel" value="chat_<a href="https://www.baidu.com/s?wd=sql&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBuymdPj0vnAFBmWbdmWRv0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHmYn1nknWTk" target="_blank" class="baidu-highlight">sql</a>"/>
<jsp:setProperty property="<a href="https://www.baidu.com/s?wd=sql&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dBuymdPj0vnAFBmWbdmWRv0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHmYn1nknWTk" target="_blank" class="baidu-highlight">sql</a>query" name="sel" value="select * from chat_content where receiver like('%1111%')"/>
tst.updateBean updateBean 是一个类,这里自己写的函数。包括:连接数据库,执行数据库语言(select ,update,delete insert 函数),database为数据表名,sel为实例,sqlquery为sql语言。
预知updateBean类内容如何,这里要实现多出执行sql语言,只需要在别处添加一句:
<jsp:setProperty property="sqlquery" name="sel" value="select * from chat_content where receiver like('%1111%')"/>
<%
sel.query() ;//执行即可
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |