0
Iam新增了Ajax標記..每當我嘗試執行這些時,HTML部分都按預期工作。但阿賈克斯標籤不工作..Jsp ajax標記無法在jsp中工作..無法加載標記處理程序類異常
獲取無法加載標籤處理類異常 「org.ajaxtags.tags.AjaxSelectTag」 ..
<%@ taglib uri="/WEB-INF/ajaxtld/ajaxtags.tld" prefix="ajax" %>
<html>
<head>
<title>AJAX JSP Tag Library</title>
<script type="text/javascript" src="js/prototype-1.6.0.3.js"></script>
<script type="text/javascript" src="js/scriptaculous/scriptaculous.js"></script>
<script type="text/javascript" src="js/overlibmws/overlibmws.js"></script>
<script type="text/javascript" src="js/ajaxtags-1.2-beta1.js"></script>
<link type="text/css" rel="stylesheet" href="/WEB-INF/css/ajaxtags.css" />
<link type="text/css" rel="stylesheet" href="/WEB-INF/css/displaytag.css" />
</head>
<body>
<form>
Make:
<select id = "make" name = "make">
<option value="">Select make</option>
<c:forEach items="${makes}" var="make">
<option value="${make}">${make}</option>
</c:forEach>
</select>
Model:
<select id="model" name="model" >
<option value="">Select model</option>
</select>
<input type="button" value="read">
<div id="tar"></div>
</form>
<ajax:select baseUrl="$Sample/samplejava" source="make" target="model" parameters="make={make}" />
</body>
</html>
servlet的部分定義如下..
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class samplejava extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet samplejava</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet samplejava at " + request.getContextPath() + "</h1>");
out.println("Here is the response...");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
try {
String res = request.getParameter("make");
RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
PrintWriter out = response.getWriter();
out.println(res);
response.getWriter().write("hai!! this is response...");
response.sendRedirect("success.jsp");
} catch (Exception e) {
response.sendRedirect("error.jsp");
}
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
任何人都可以提出請...
使用jQuery/javascript會很容易,很好,靈活,然後ajax標籤。 – 2014-09-04 09:38:27
K.但爲什麼這不起作用? – deeban 2014-09-04 09:39:43
你可以用你的jre版本驗證ajax標籤jar版本嗎?如果它不同,你可以使用兼容jar來測試你的java版本。 – RE350 2014-09-04 18:31:18