/** * 添加自制JavaScript脚本到当前Web界面当中 * * @param sprite */ public void addJavaScripts(JavaScript sprite) { this.addJavascriptInterface(sprite.getObject(), sprite.getName()); }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html; charset=GBK"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); int id = Integer.parseInt(request.getParameter("id")); String name = request.getParameter("name"); String xuehao = request.getParameter("number"); String sex = request.getParameter("sex"); String sszy = request.getParameter("master"); String bbzy = request.getParameter("doctor"); String sd = request.getParameter("masterTeacher"); String nbbd = request.getParameter("doctorTeacher"); String rxcj = request.getParameter("score"); String cjpm = request.getParameter("cjpm"); String beizhu = request.getParameter("beizhu"); String male = "男"; String female = "女"; Sbld sbldstudent = (Sbld) BasicDAO.queryById(Sbld.class, id); sbldstudent.setId(id); sbldstudent.setName(name); sbldstudent.setXuehao(xuehao); if (sex.equals("male")) { sbldstudent.setSex(male); } else { sbldstudent.setSex(female); } sbldstudent.setSszy(sszy); sbldstudent.setBbzy(bbzy); sbldstudent.setSd(sd); sbldstudent.setNbbd(nbbd); sbldstudent.setRxcj(rxcj); sbldstudent.setCjpm(cjpm); sbldstudent.setBeizhu(beizhu); try { BasicDAO.update(sbldstudent); out.println(JavaScript.alertandRedirect("保存成功", "ApplicationInfo.jsp")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); out.println(JavaScript.alertandBack("保存失败")); } } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
public Object call( final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { JavaObjectWrapper jcw = (JavaObjectWrapper) thisObj; Method method = this.getBestMethod(args); if (method == null) { throw new EvaluatorException( "No method matching " + this.className + " with " + (args == null ? 0 : args.length) + " arguments."); } Class[] actualArgTypes = method.getParameterTypes(); int numParams = actualArgTypes.length; Object[] actualArgs = args == null ? new Object[0] : new Object[numParams]; boolean linfo = loggableInfo; if (linfo) { Object javaObject = jcw.getJavaObject(); logger.info( "call(): Calling method " + method.getName() + " on object " + javaObject + " of type " + this.getTypeName(javaObject)); } JavaScript manager = JavaScript.getInstance(); for (int i = 0; i < numParams; i++) { Object arg = args[i]; Object actualArg = manager.getJavaObject(arg, actualArgTypes[i]); if (linfo) { logger.info( "call(): For method=" + method.getName() + ": Converted arg=" + arg + " (type=" + this.getTypeName(arg) + ") into actualArg=" + actualArg + ". Type expected by method is " + actualArgTypes[i].getName() + "."); } actualArgs[i] = actualArg; } try { Object raw = method.invoke(jcw.getJavaObject(), actualArgs); return manager.getJavascriptObject(raw, scope); } catch (IllegalAccessException iae) { throw new IllegalStateException("Unable to call " + this.className + ".", iae); } catch (InvocationTargetException ite) { throw new WrappedException( new InvocationTargetException( ite.getCause(), "Unable to call " + this.className + " on " + jcw.getJavaObject() + ".")); } catch (IllegalArgumentException iae) { StringBuffer argTypes = new StringBuffer(); for (int i = 0; i < actualArgs.length; i++) { if (i > 0) { argTypes.append(", "); } argTypes.append(actualArgs[i] == null ? "<null>" : actualArgs[i].getClass().getName()); } throw new WrappedException( new IllegalArgumentException( "Unable to call " + this.className + ". Argument types: " + argTypes + ".", iae)); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html; charset=GBK"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; out.write('\r'); out.write('\n'); String title = request.getParameter("title"); String content = request.getParameter("content"); String filename = request.getParameter("filename"); String fileurl = request.getParameter("fileurl"); Gcxknews gcxknews = new Gcxknews(); gcxknews.setTitle(title); gcxknews.setContent(content); gcxknews.setPubtime(new Date()); gcxknews.setFilename(filename); gcxknews.setFileurl(fileurl); try { BasicDAO.save(gcxknews); out.println(JavaScript.alertandRedirect("保存成功", "gcxknewslist.jsp")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); out.println(JavaScript.alertandBack("保存失败")); } out.write("\r\n"); out.write("\r\n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }