类 UserAgentDirective

所有已实现的接口:
Directive, HttpDirective, freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel

@Component public class UserAgentDirective extends AbstractTemplateDirective
userAgent user agent分析指令

参数列表

parameter list

パラメータリスト

  • userAgent:user agent,为空时取当前请求的user agent

返回结果

return result

戻り値

  • object.ip:客户端ip
  • object.browser:浏览器
  • object.browserType:浏览器类型
  • object.browserVersion:浏览器版本
  • object.operatingSystem:操作系统
  • object.operatingSystemVersion:操作系统版本
  • object.deviceType:设备类型
  • object.userAgent:user agent

使用示例

usage example

使用例

<@tools.userAgent>${a.deviceType}</@tools.userAgent>

<script>
 $.getJSON('${site.dynamicPath}api/directive/tools/userAgent', function(data){
   console.log(data.deviceType);
 });
 </script>
 
  • 字段详细资料

    • parser

      public static com.blueconic.browscap.UserAgentParser parser
  • 构造器详细资料

    • UserAgentDirective

      public UserAgentDirective()
  • 方法详细资料

    • execute

      public void execute(RenderHandler handler) throws IOException, freemarker.template.TemplateException
      参数:
      handler -
      抛出:
      IOException
      freemarker.template.TemplateException