2017.08.17

来源:互联网 发布:js 字符串对象转数组 编辑:程序博客网 时间:2024/06/06 12:27

解决Idea出现cannot resolve symbol

Idea cannot resolve symbol 代码边红色 现象的2中解决方法:
1.File-->Invalidated cache
 
如果不行,可能是maven的问题,执行第2种:
 
2.reimport maven,重新把maven import到Idea中。


修改贫困生mr程序.

1.把有关useragent的都注释了.

System.out.println( context.getConfiguration().get(Config.UA_URL));String UAUrl =  context.getConfiguration().get(Config.UA_URL);String json = JsonParseUtil.loadJson(UAUrl);JSONObject obj = null;try {    obj = new JSONObject(json);    int userAgentTag = obj.getInt("UserAgent");    System.out.println("<--->"+userAgentTag);    if (userAgentTag == 1){        gameAppSum = new IntWritable(1);    }    if (userAgentTag == 3 ) {        learnAppSum = new IntWritable(1);    }    if (userAgentTag == 4){        consumptionAPPState = new IntWritable(1);    }    if (userAgentTag == 5){        orderMealAPPState = new IntWritable(1);    }    if (userAgentTag == 13){        videoAppSum = new IntWritable(1);    }} catch (JSONException e) {    e.printStackTrace();}

我准备把这个url放在mr程序中的otherargs中.

1.

otherArgs[7] = "http://192.168.20.60:8080/user-agent-service/UserAgentTag?word=";
conf.set(Config.UA_URL,otherArgs[7]);
public static final String UA_URL = "http://192.168.20.60:8080/user-agent-service/UserAgentTag?word=";

有set就用get来获取

String UAUrl =  context.getConfiguration().get(Config.UA_URL);

http://192.168.20.60:8080/user-agent-service/UserAgentTag?word=


正则表达式

1.find()方法是部分匹配,是查找输入串中与模式匹配的子串,如果该匹配的串有组还可以使用group()函数。

matches()是全部匹配,是将整个输入串与模式匹配,如果要验证一个输入的数据是否为数字类型或其他类型,一般要用matches()。

 

2.Pattern pattern= Pattern.compile(".*?,(.*)");

    Matcher matcher = pattern.matcher(result);

  if (matcher.find()) {
   return matcher.group(1);
  }


  1.  //拿到map集合中的key的Set集合  
  2.         Set<String> keySet = map.keySet();
Map  map = new Hashmap();//创建一个mapmap.put("key","value");//给map赋值String  vlaues = map.get("key");//获取map中键值为“key”的值system.out.println(vlaues );//输出结果以上代码的运行结果:value;


html中是+号的意思,通过 GET方式传值的时候,+号会被浏览器处理为空。。需要转换为%2b


\\D*

匹配非数字字符的字符串 
*   表示匹配前面的子表达式零次或多次(大于等于0次)。例如,zo*能匹配“z”,“zo”以及“zoo”。*等价于{0,}。