如何从java列表中获取字符串值

尼蓬·维达沙纳

我想从列表中选择一个。列表包含五个值。**我想从列表中找到一个值。当列表中有 **importer 时,我想做点什么我给了我的电源线,我创建了一个名为roleosuser的列表如何检查 roleosuser 列表有进口商。当它有进口商我想做某事..我该怎么做

@RequestMapping(path = "/view/all/posted-applications/importer")
public String viewallApplicationofIMPORTER(Model model) {
    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    long userId = 0;
    List <String> roleosuser;
    if (principal != null && principal instanceof AuthenticatedUser) {
        AuthenticatedUser auth = (AuthenticatedUser) principal;
        userId = auth.getUserId();
        roleosuser= auth.getUserRoles();

        if(roleosuser.get(0)) {
            System.out.println("importer equals "+roleosuser);
        }
        model.addAttribute("userID", userId);
    }
    return "applicationManageIMPORTER";
}

我想从我的列表中获取“IMPORTER”值。List具有进口商和代理价值。这该怎么做?

虚拟机

用这个

 if(roleosuser.contains("IMPORTER")) {
         System.out.println("found");
         // do whatever you want
     }

或者

如果你想知道索引,你可以使用它

roleosuser.indexOf("IMPORTER")

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

R如何获取字符串中的字符列表

如何获取字符串C ++中字符的值?

如何从dataweave 2.0中的地图列表中获取字符串值?

如何从列表框中获取字符串

如何从用户选择的列表框中获取字符串值?

Java:如何获取字符串的枚举值?

从Java中的枚举获取字符串值

如何从RecyclerView中的EditText获取字符串值?

如何从流中获取字符串数组值?

如何获取字符串中的括号值

如何从Python3中给定的值列表中获取字符串中每个字符的值?

如何从Java中的DataInputStream获取字符串?

如果存在子字符串,如何从列表中获取字符串

如何从tf.tensor中获取字符串值,其中dtype是字符串

如何在Java中获取字符串中双引号之间的字符串

如何使用SQL查询从字符串列表中获取字符串

从 Bash 中的变量列表中获取字符串

如何获取字符列表中的所有子字符串(Python)

如何从列表中获取对象中的字符串值?

我想从列表中获取字符串

PySpark-从列表中获取字符串位置

Haskell从列表理解中获取字符串

从文本列表中获取字符串数组C ++

在Pandas DataFrame中获取字符串而不是列表

从以逗号分隔的列表中获取字符串

在Java中的特殊字符之前获取字符串的值

如何在jQuery中获取字符串中所有无效字符的值?

如何从javascript中的值获取字符串文字(字符数组?)?

在字符串列表中搜索字符串以获取字符串