RESTClient到底该怎么提交JSON对象啊啊啊
1个回答
推荐于2016-05-27
展开全部
在model层
public List<Map<String,String>> query() throws SQLException
{
List<Map<String,String>> listmap=new ArrayList<Map<String,String>>();
Connection conn=null;
ResultSet rs=null;
String query="SELECT * FROM COURSE";
Statement st=null;
conn=Conn.getConnection();
st=conn.createStatement();
rs=st.executeQuery(query);
while(rs.next())
{
Map<String,String> map=new HashMap<String, String>则顷答();
map.put("coursetypeid", rs.getString("COURSE_TYPE_ID"));
map.put("coursename", rs.getString("COURSE_NAME"));
map.put("publish", rs.getString("PUBLISH"));
map.put("publishtime", rs.getString("PUBLISH_TIME"));
map.put("coursenumber", rs.getString("CHAPTER_NUMBER"孙慧));
map.put("courseid", rs.getString("COURSE_ID"));
map.put("coursedesc", rs.getString("COURSE_DESC"));
listmap.add(map);
}
conn.close();
return listmap;
}
控制层
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
ConImp c=new ConImp();
String json= c.QueryCourseInfo();
response.getWriter().write(json);
}
最后在页面通过转换获得并显示。乎橘
public List<Map<String,String>> query() throws SQLException
{
List<Map<String,String>> listmap=new ArrayList<Map<String,String>>();
Connection conn=null;
ResultSet rs=null;
String query="SELECT * FROM COURSE";
Statement st=null;
conn=Conn.getConnection();
st=conn.createStatement();
rs=st.executeQuery(query);
while(rs.next())
{
Map<String,String> map=new HashMap<String, String>则顷答();
map.put("coursetypeid", rs.getString("COURSE_TYPE_ID"));
map.put("coursename", rs.getString("COURSE_NAME"));
map.put("publish", rs.getString("PUBLISH"));
map.put("publishtime", rs.getString("PUBLISH_TIME"));
map.put("coursenumber", rs.getString("CHAPTER_NUMBER"孙慧));
map.put("courseid", rs.getString("COURSE_ID"));
map.put("coursedesc", rs.getString("COURSE_DESC"));
listmap.add(map);
}
conn.close();
return listmap;
}
控制层
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
ConImp c=new ConImp();
String json= c.QueryCourseInfo();
response.getWriter().write(json);
}
最后在页面通过转换获得并显示。乎橘
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询