ssm統合でのcontrollerインタフェースの実装方法(Vueを統合するためのステップの1つ)


ssm統合のためのコントロールインタフェース(Vueを統合するためのステップの1つ)
1.pomファイルを修正し、非同期通信の依存を追加
2.springプロファイルの変更
3.コントロールのメソッドに注記@ResponseBodyを追加
//これはjsonに戻ります
 
1.pomファイルは以下の通りです.
 
    
      com.fasterxml.jackson.core
      jackson-databind
      2.7.4
    
    
      com.fasterxml.jackson.core
      jackson-core
      2.7.4
    
    
      com.fasterxml.jackson.core
      jackson-annotations
      2.7.4
    

 
2.springプロファイルに追加する内容


    
        
            
                
                
            
        
    
    
        
            
                
            
        
    

    
        
            
                
                    
                    
                    
                
                
                    
                    
                    
                
                
                    
                    
                    
                
                
                    
                    
                    
                
            
        
    

3.具体例
(コントロール内はどう書きますか)
@RequestMapping(value = "getJson", method = RequestMethod.GET)
	@ResponseBody
	public Map getJson(HttpSession httpSession){
		Map map = new HashMap();
		List cs = new LinkedList();
		cs.add(new Category());
		cs.add(new Category());
		cs.add(new Category());
		cs.add(new Category());
		try {
			map.put("errorCode", 0);
			map.put("message", "hello");
			map.put("cs",cs);
		} catch (Exception e) {
			map.put("errorCode", 1);
			map.put("errorMessage", "    ");
		}
		System.out.println("    controllor");
		System.out.println("       ");
		return map;

	}

 
最後に,前後端分離はドメイン間問題にも関与し,フロントエンドが要求ブロックを行い,変換またはバックグラウンドをフィルタ処理する必要がある.