主题 : 报错,怎么解决 |
级别: 商业授权用户
|
1# 发表于:2015-04-08 17:24:03 IP:121.45.*.*
|
||||
---|---|---|---|---|---|
级别: 商业授权用户
|
3# 发表于:2015-04-08 17:26:33 IP:121.47.*.*
回复第2楼package com.jeecms.client.web;
import java.util.List; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.jeecms.client.service.NewsService; @Controller @RequestMapping("/news") public class NewsController { /** * 获取新闻列表接口 * @param newstype * @param startid * @param offset * @return fufan */ @RequestMapping(value = "/getNewslist") @SuppressWarnings("rawtypes") public String getNews(/*@RequestParam("newstype") int newstype, @RequestParam("startid") int startid,@RequestParam("offset") int offset*/){ JSONObject obj = new JSONObject(); JSONArray jsonArray = new JSONArray(); try{ List list = newsService.getNews(0, 0, 100); for(int i = 0; i < list.size(); i++){ JSONObject jsonObject = new JSONObject(); Object [] object = (Object[]) list.get(i); jsonObject.put("id", object[0] == null ? "" :object[0].toString()); jsonObject.put("title", object[1] == null ? "" :object[1].toString()); jsonObject.put("summary", object[2] == null ? "" :object[2].toString()); jsonObject.put("picurl", object[5]== null ? "" :object[5].toString()); jsonObject.put("ptime", object[6] == null ? "" :object[6].toString()); jsonObject.put("commentNum", object[8] == null ? "" : object[6].toString()); jsonArray.put(jsonObject); } }catch(Exception e){ try { obj.put("status", -1); } catch (JSONException e1) { e1.printStackTrace(); } e.printStackTrace(); } try { obj.put("status", 1); obj.put("newsList", jsonArray); } catch (JSONException e) { e.printStackTrace(); } return obj.toString(); } @Autowired private NewsService newsService; } 在 jeecms-servlet-admin-action.xml 加入了 <bean id="newsController" class="com.jeecms.client.web.NewsController" /> |
||
---|---|---|---|
级别: 商业授权用户
|
7# 发表于:2015-04-08 17:36:56 IP:121.47.*.*
回复第6楼 我上面写的方法,一定要在jeecms-servlet-admin-action.xml 中配置太能使用吗, 我有@Controller 注解呀,为什么不能访问,有没有解决方法
|
||
---|---|---|---|
级别: 版主
|
8# 发表于:2015-04-08 17:39:16 IP:111.76.*.*
二次开发不在服务范围内,如果有需要,可以联系售前人员,我们提供功能定制服务
|
||
---|---|---|---|
1
共1页