日期:2014-05-16 浏览次数:20907 次
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:te="http://www.seasar.org/teeda/extension" xmlns:h="http://java.sun.com/jsf/html" xml:lang="ja" lang="ja"> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" /> <script> $(function(){ $("#checkNickname").click( function() { var fields = new Object(); fields["component"] = "helloLogic"; fields["action"] = "ajaxNicknameCheck"; fields["AjaxParam1"] = "local"; fields["nickName"] = $("#nickName").val(); $.ajax({ type : "POST", url : "./my.ajax", data : fields, success : function(msg){ alert(msg); } }); }); }); </script> </head> <body> <form id="form"> <input type="text" id="nickName" /> <input type="button" id="checkNickname" value="check" /> </form> </body> </html>
... <servlet> <servlet-name>ajaxServlet</servlet-name> <servlet-class>org.seasar.teeda.ajax.AjaxServlet</servlet-class> <load-on-startup>3</load-on-startup> </servlet> ... <servlet-mapping> <servlet-name>ajaxServlet</servlet-name> <url-pattern>*.ajax</url-pattern> </servlet-mapping> ...
... public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doAjax(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doAjax(request, response); } ...
String componentName = request .getParameter(AjaxConstants.REQ_PARAM_COMPONENT); String method = request.getParameter(AjaxConstants.REQ_PARAM_ACTION); if (method == null) { method = AjaxConstants.DEFAULT_AJAX_METHOD; } ...
... if (!method.startsWith(AJAX_PREFIX)) { MetaDef meta = def.getMetaDef(AjaxConstants.TEEDA_AJAX_META); if (meta == null) { throw new ServletException("Ajax Component Name[" + componentName + "] is not public."); } } ...
... ComponentDef def = getComponentDefNoException(componentName); ... Object obj = def.getComponent(); ...
... Object[] args = this.setRequestParameter(request, obj); ...