1.都是經(jīng)常用的jsp來調(diào)用Servlet如果現(xiàn)在我把從數(shù)據(jù)庫得到的數(shù)據(jù)錄入到j(luò)sp頁面上?? 就是在jsp頁面上寫了一個(gè)功能,讓他能夠自動(dòng)導(dǎo)入到j(luò)sp頁面上這個(gè)時(shí)候我用Servlet 來調(diào)用 jsp? 會(huì)有什么作用??2.反過來呢?,如果真的麻煩的話,怎么把jsp寫的錄入功能代碼塊轉(zhuǎn)移到Servlet?下面是我寫的jsp部分<table?border="1"?width="100%">
????<tr>
????????<th>書籍Id號(hào)</th>
????????<th>書籍名稱</th>
????????<th>借閱狀態(tài)</th>
????????<th>書籍?dāng)?shù)量</th>
????????<th>書籍作者</th>
????</tr>
????<c:forEach?var="row"?items="${result.rows}">
????????<tr>
????????????<div>?<td><c:out?value="${row.id}"/></td></div>
????????????<div><td><c:out?value="${row.name}"/></td></div>
????????????<div><td><c:out?value="${row.flag}"/></td></div>
????????????<td><c:out?value="${row.number}"/></td>
????????????<td><c:out?value="${row.author}"/></td>
????????</tr>
????????</div>
????</c:forEach>
</table>
<%
????String?userName=(String)session.getAttribute("UserName");
%>
</body>下面是我寫的servlet:
@WebServlet(name?=?"HelloServlet",?urlPatterns?=?{"/HelloServlet"})
public?class?HelloServlet?extends?HttpServlet?{
????public?void?doGet(HttpServletRequest?request,?HttpServletResponse?response)
????????????throws?IOException,?ServletException
????{}
????public?void?doPost(HttpServletRequest?request,?HttpServletResponse?response)
????????throws?IOException,?ServletException?{
????request.getRequestDispatcher("Select.jsp").forward(request,response);
????}
jsp 和servlet的相互調(diào)用相關(guān)問題
Rvie
2018-07-18 20:07:37