我是jQuery和AJAX的初学者,我只想从JSP文件中获取一个值到HTML5
所以我可以将该值放入我的HTML5源代码中的<textarea>
。
请帮帮我,谢谢
这是源文件:
<html>
..
<body>
<div data-role="content">
<div data-role="fieldcontain">
<form method="post" action="ShowQuestion.jsp" name="frm" > <!--using post action, transfer Element Information-->
<label for="theQuestion"></label>
<div id="QuestionLog"> <!--to contain my question title and content-->
<input type="text" id="qnaTitle" name="qnaTitle" > </input> <!--input title-->
<textarea cols="20" rows="5" wrap="hard" id="qnaContent" name="qnaContent">
</textarea> <!--input content-->
</div>
</form>
..
</body>
</html>
Connection conn;
PreparedStatement pstmt;
ResultSet rs=null;
pstmt = conn.prepareStatement("select * from question "); // query
rs = pstmt.executeQuery(); // execute that query
while(rs.next()) {
String title=rs.getString(1); //save the query's result
String content = rs.getString(2); //save the query's result,too
}
}catch(Exception e) {
e.printStackTrace(); // print the Exception Message
}
答案 0 :(得分:0)
当你使用jquery时,你获得了价值(而且你确定它),你只需要做 是
$('#qnaContent').val(content); // Considering that the result string is stored in "content"