推荐WindowsLiveWrite代码插入插件 source code formatter

   1: package com.momas.helloworld.server;
   2:  
   3: import com.momas.helloworld.client.GreetingService;
   4: import com.momas.helloworld.shared.FieldVerifier;
   5: import com.google.gwt.user.server.rpc.RemoteServiceServlet;
   6:  
   7: /**
   8:  * The server side implementation of the RPC service.
   9:  */
  10: @SuppressWarnings("serial")
  11: public class GreetingServiceImpl extends RemoteServiceServlet implements
  12:         GreetingService {
  13:  
  14:     public String greetServer(String input) throws IllegalArgumentException {
  15:         // Verify that the input is valid. 
  16:         if (!FieldVerifier.isValidName(input)) {
  17:             // If the input is not valid, throw an IllegalArgumentException back to
  18:             // the client.
  19:             throw new IllegalArgumentException(
  20:                     "Name must be at least 4 characters long");
  21:         }
  22:  
  23:         String serverInfo = getServletContext().getServerInfo();
  24:         String userAgent = getThreadLocalRequest().getHeader("User-Agent");
  25:  
  26:         // Escape data from the client to avoid cross-site script vulnerabilities.
  27:         input = escapeHtml(input);
  28:         userAgent = escapeHtml(userAgent);
  29:  
  30:         return "Hello, " + input + "!<br><br>I am running " + serverInfo
  31:                 + ".<br><br>It looks like you are using:<br>" + userAgent;
  32:     }
  33:  
  34:     /**
  35:      * Escape an html string. Escaping data received from the client helps to
  36:      * prevent cross-site script vulnerabilities.
  37:      * 
  38:      * @param html the html string to escape
  39:      * @return the escaped string
  40:      */
  41:     private String escapeHtml(String html) {
  42:         if (html == null) {
  43:             return null;
  44:         }
  45:         return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;")
  46:                 .replaceAll(">", "&gt;");
  47:     }
  48: }

 

推荐使用WindowsLive Write 的Source Code Formatter插件,

下载地址如下:

Source Code Formatter

转载于:https://www.cnblogs.com/shushanju/archive/2013/05/05/3060501.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值