首页>代码>bootstrap+jquery+mustache+springmvc+idworker整合demo代码>/mustache_demo/src/main/java/com/javaniu/web/CommentController.java
                
                package com.javaniu.web;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.javaniu.module.Comment;
import com.javaniu.util.IdWorker;
@Controller
@RequestMapping({ "comment" })
public class CommentController {
	ConcurrentHashMap<Long, Comment> comments = new ConcurrentHashMap<Long, Comment>();
	@RequestMapping(value = { "" }, method = { RequestMethod.GET })
	public @ResponseBody
	Collection<Comment> comments() {
		return comments.values();
	}
	@RequestMapping(value = { "create" }, method = { RequestMethod.GET })
	public @ResponseBody
	Comment create(
			@RequestParam(value = "content", required = true) String content) {
		IdWorker worker2 = new IdWorker(2);
		Comment comment = new Comment();
		// random id+current time
		long id = worker2.nextId();
		// 把content解码为utf8编码的正常内容
		try {
			content = new String(content.getBytes("iso8859-1"), "utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		comment.setContent(content);
		comment.setId(id);
		comments.put(id, comment);
		return comment;
	}
	@RequestMapping(value = { "remove" }, method = { RequestMethod.GET })
	public @ResponseBody
	Comment remove(@RequestParam(value = "id", required = true) Long id) {
		Comment comment = comments.remove(id);
		return comment;
	}
}
 最近下载更多
最近下载更多
                
                鸦葱     LV4
                2021年6月2日
            
            
        
                best2018     LV46
                2019年1月24日
            
            
        
                shaozhong     LV1
                2018年12月2日
            
            
        
                lxl1234     LV9
                2018年10月28日
            
            
        
                gaogaoyanjiu     LV6
                2018年9月14日
            
            
        
                a10320773     LV2
                2018年8月4日
            
            
        
                hancy666     LV33
                2018年6月21日
            
            
        
                cfy8814064     LV1
                2018年4月4日
            
            
        
                江湖危险快点跑     LV7
                2018年3月26日
            
            
        
                historyU     LV1
                2017年12月22日
            
            
         最近浏览更多
最近浏览更多
                
                win1991     LV6
                2023年5月15日
            
            
        
                srl2881552     LV10
                2022年9月6日
            
            
        
                黑     LV7
                2022年7月5日
            
            
        
                p521102212     LV1
                2022年5月14日
            
            
        
                氼乚-----------     LV5
                2022年3月18日
            
            
        
                1615651451     LV2
                2021年12月7日
            
            
        
                nihaomasb     LV7
                2021年9月4日
            
            
        
                鸦葱     LV4
                2021年6月2日
            
            
        
                秦sir3067683450     LV10
                2021年6月2日
            
            
        
                dfsfh43253hg     LV1
                2021年3月16日
            
            
        
 
     
                 
                