2024年4月12日发(作者:)
ajax调用java方法
ajax调用java后台的方法,其实是通过url链接来访问。下面是店铺为大家带来一篇
ajax调用java方法,希望对大家有所帮助。
ajax调用java方法(一)
public void doPost(HttpServletRequest req, HttpServletResponse
throwsServletException,ption{
//得到类名、方法名和参数
String methodName=ameter("methodName");
String className=ameter("className");
Object[] objs=ameterValues("params");
Object targetObj;
try {
targetObj = e(className).newInstance();
Object obj=Method(targetObj, methodName, objs);
resp)
sp(resp, obj);
} catch (InstantiationException e) {
tackTrace();
} catch (IllegalAccessException e) {
tackTrace();
} catch (ClassNotFoundException e) {
tackTrace();
} catch (NoSuchMethodException e) {
tackTrace();
} catch (InvocationTargetException e) {
tackTrace();
}
}


发布评论