phprpc for javascript 从java中获取数据 返回不了数据的解决方法
程序员文章站
2022-05-12 09:05:24
...
返回获取不到返回值的jsp写法:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="org.phprpc.PHPRPC_Server"%>
<%@page import="com.test.service.MyHello"%>
<%
MyHello hello=new MyHello();
PHPRPC_Server server=new PHPRPC_Server();
server.add(hello);
server.start(request,response);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
去掉要访问的jsp中所有的HTML的内容,只留下jsp自己的代码即可获得返回值,修改后为:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="org.phprpc.PHPRPC_Server"%>
<%@page import="com.test.service.MyHello"%>
<%
MyHello hello=new MyHello();
PHPRPC_Server server=new PHPRPC_Server();
server.add(hello);
server.start(request,response);
%>
如果返回的是对象,通过 "returnName.attributeName"的形式即可访问返回对象的属性
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="org.phprpc.PHPRPC_Server"%>
<%@page import="com.test.service.MyHello"%>
<%
MyHello hello=new MyHello();
PHPRPC_Server server=new PHPRPC_Server();
server.add(hello);
server.start(request,response);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
去掉要访问的jsp中所有的HTML的内容,只留下jsp自己的代码即可获得返回值,修改后为:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="org.phprpc.PHPRPC_Server"%>
<%@page import="com.test.service.MyHello"%>
<%
MyHello hello=new MyHello();
PHPRPC_Server server=new PHPRPC_Server();
server.add(hello);
server.start(request,response);
%>
如果返回的是对象,通过 "returnName.attributeName"的形式即可访问返回对象的属性