webx3 ajax实践

webx3处理ajax很简单,需要注意的是别忘了家cache-control,今天没有加这个,IE浏览器下会cache住ajax请求。

public class RateAdd {

    @Autowired
    private RateService         rateService;

    @Autowired
    private HttpServletResponse response;

    public void execute(@Param("placeId") Long placeId) throws IOException {
        response.addHeader("Cache-Control", "no-cache");
        response.setContentType("application/json");
        PrintWriter out = response.getWriter();
        boolean result = false;
      
        if (placeId == null) {
            out.write(String.valueOf(result));
            return;
        }

        result = rateService.createRate(AuthContext.getContext().getMemberId(), placeId);
        out.write(String.valueOf(result));

    }
}

你可能感兴趣的:(Ajax)