JSP获取数据库信息

JSP获取数据库信息,第1张

<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">

<tr align="center" height="25" bgcolor="d3eaef">

<td width="5%">

编号

</td>

<td width="10%">

标题

</td>

<td width="23%">

内容

</td>

<td width="10%">

发表日期

</td>

<td width="16%">

基本 *** 作

</td>

</tr>

<%

//获取新闻信息集合,newList是从后台返回来的集合变量

List nList = (List) sessiongetAttribute("newList");

NewsEntity new = null;

if (nListsize() <= 0) {

%>

<tr height="22" bgcolor="#FFFFFF" align="center">

<td colspan="9" align="center">

暂无新闻信息

</td>

</tr>

<%

} else {

for (int i = 0; i < nListsize(); i++) {

new = (NewsEntity) mListget(i);

%>

<tr height="22" bgcolor="#FFFFFF" align="center">

<td>

<%=newgetId() %>

</td>

<td>

<%=newgetTitle() %>

</td>

<td>

<%=newgetContent() %>

</td>

<td>

<%=newtime() %>

</td>

<td>

<a href="MusicServletforward=getNewsDetailById&ID=<%=newgetId()%>" >

<span class="STYLE2">编辑</span> </a> | 

<a href="MusicServletforward=doDelNewsById&ID=<%=newgetId()%>"

onclick="return confirm('您确定要删除该条信息吗?');"><span

class="STYLE2">删除</span> </a>

</td>

</tr>

<%

}

}

%>

</table>

<script>

function load(){

var json = {"program": [{"code": "","primaryid": "","seriesflag": "0","fileurl": "","topic_id": null,

"name": "森林","id": "","sequence": "4",}],"topic": {"enterimg": "","code": "","primaryid": "","fileurl": "",}}; 

alert(jsonprogram[0]code);

alert(jsonprogram[0]name);

   alert(jsontopicfileurl);

}

</script>

比如在后台设置一个值在request里面,requestsetAttribute("param",param);

在jsp页面就可以这样获取,${param}; el表达式。

在页面传值到后台中,第一种post方式,提交表单时。

<form action="xxxdo" method="post">

<input type="text" name="username"/>

<input type="password" name="password"/>

<input type="submit"/>

</form>

点击提交按钮后在后台获取Username,和password

String username =requestgetParamter("username");

String password=requestgetParamter("password");

如果是get方式提交的话

举个例子:

<a href="xxxdoparam1=123">查看</a>

那么在后在获取也是一样的

String param1=requestgetParamter("param1");

可以自定义属性的,比如

<input name="templateId" id="templateId" type="checkbox"

onclick="unselectall()" st="${templatestatusVer}"

value="${templateidVer}" bj="${templateid }" mng="true"

del="del" />

这个隐藏的input就存放了很多template的属性,其他就不用多说了吧?

可以使用连接拼接的方式:

首先,var s = documentgetElementById("文本框ID")value;

然后在连接里拼接上值:

<<a href='' onclick="locationhref='anotherjspnumber=' +s">添加数量</a>

以上就是关于JSP获取数据库信息全部的内容,包括:JSP获取数据库信息、jsp页面通过接口获取数据并解析,后台数据返回如下,只需要program里的code、name,topic里的fileurl、怎么在jsp页面获取java在后台产生的变量值,以及从页面传输居到java程序(程序不是嵌在页面的)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/10054433.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-04
下一篇2023-05-04

发表评论

登录后才能评论

评论列表(0条)

    保存