枚举如下:
public enum UinUserType {
pc,
mobilePhone
}
访问地址:
127.0.0.1:8080/sxxx/sxx/test.htm?userType=pc
action解析方式:
String userType = request.getParameter("userType");UinUserType uUserType = null;
if(UinUserType.pc.name().equals(userType)){
uUserType = UinUserType.pc;
}else if(UinUserType.mobilePhone.name().equals(userType)){
uUserType = UinUserType.mobilePhone;
}
this.uinUserType = uUserType;
本文介绍了一种通过枚举类型来解析HTTP请求参数的方法。具体实现为定义了一个名为UinUserType的枚举,包含pc和mobilePhone两个选项,并展示了如何根据请求参数userType的值来获取对应的枚举成员。
1万+

被折叠的 条评论
为什么被折叠?



