@RequestMapping(value="/selectNode")
public ModelAndView selectNode(HttpServletRequest request,HttpServletResponse reponse) throws Exception
{
  String t=request.getParameter("id");
  int id=Integer.parseInt(t);
  AbstractApplicationContext context=new ClassPathXmlApplicationContext("MyBatis-Spring.xml");
  NodeserviceDao nodeservice =(NodeserviceDao)context.getBean("nodeserviceimpl");
  
  Node nodes= nodeservice.selectNode(id);
  String x=String.valueOf(nodes.getPort1()) ;
  String y=String.valueOf(nodes.getPort2()) ;
  Map<String,Object> result=new HashMap<String, Object>();  
  result.put("Port1", x);
  result.put("Port2", y);
  return new ModelAndView(StringUtils.EMPTY,StringUtils.EMPTY,result);
 
}
服务端的代码是这样的 我想在客户端读到“Port1,Port2”这2个值
该怎么读SpringMVC

解决方案 »

  1.   

    直接${Port1}--------${Port2}就行了
      

  2.   

    EL表达式${Port1 }   ${Port2 }
      

  3.   

    我要的不是在jsp上取值 我的客户端就是一个java项目不是web项目
    就是说我在java项目中通过http请求给服务器 服务器返回数据我要怎么拿出来
      

  4.   

    我是通过httpClient发送的请求 不是在jsp里读数据
      

  5.   

    spring mvc本来就是做java web (b/s)的,你为什么拿来做c/s架构呢
      

  6.   

    @RequestMapping(value="/selectNode")
    @ResponseBody
    public String selectNode(HttpServletRequest request,HttpServletResponse reponse) throws Exception
    {
      String t=request.getParameter("id");
      int id=Integer.parseInt(t);
      AbstractApplicationContext context=new ClassPathXmlApplicationContext("MyBatis-Spring.xml");
      NodeserviceDao nodeservice =(NodeserviceDao)context.getBean("nodeserviceimpl");
       
      Node nodes= nodeservice.selectNode(id);
      String x=String.valueOf(nodes.getPort1()) ;    
      String y=String.valueOf(nodes.getPort2()) ;    
      Map<String,Object> result=new HashMap<String, Object>();     
      result.put("Port1", x);    
      result.put("Port2", y);
      return result.toString();
      
    }
      

  7.   

    为什么要这么搞 
    要取springmvc里面的结果,弄个webservice啊 返回字符串
    java 直接 肯定得不到这个ModelAndView对象的