前端获取到的数组是memberInfo=[陈魏,有是,刘德华,哈哈哈] 用了toString方法转为memberInfo=陈魏,有是,刘德华,哈哈哈 传到后端 去数据库查这几个人的信息 后端怎么处理
时间: 2024-02-27 08:55:15 浏览: 29
后端可以先将接收到的字符串使用 `split()` 方法分割成数组,例如:
```
let memberInfo = '陈魏,有是,刘德华,哈哈哈';
let members = memberInfo.split(',');
```
这样会得到一个名为 `members` 的数组,包含了四个成员的名字。
接下来,可以使用数组中的成员名字去数据库中查询对应的信息。具体的查询方式和语句,根据数据库类型和具体情况而定。
相关问题
@RequestMapping("/memberInfo")是做什么的的
@RequestMapping("/memberInfo")是一个 Java Spring 框架中用于处理 HTTP 请求的注解。当客户端发起一个请求并且请求的 URL 地址匹配 "/memberInfo" 时,会调用相应的处理函数来处理该请求并返回响应。具体实现方式可以参考 Spring 官方文档。通常情况下,这个注解被用于处理用户请求,返回相应的数据或者页面。
C#中Enum.Tostring的用法是什么
在C#中,Enum.ToString()方法用于将枚举常量转换为字符串表示形式。
语法:
```
public override string ToString ();
```
该方法返回一个字符串,表示当前枚举常量的名称。例如:
```
enum Color { Red, Green, Blue };
Color c = Color.Red;
Console.WriteLine(c.ToString()); // 输出 Red
```
如果需要自定义枚举常量的字符串表示形式,可以使用C#的特性(Attribute)来实现。例如:
```
enum Color {
[Description("红色")]
Red,
[Description("绿色")]
Green,
[Description("蓝色")]
Blue
};
Color c = Color.Red;
Console.WriteLine(GetDescription(c)); // 输出 红色
public static string GetDescription(Enum en)
{
Type type = en.GetType();
MemberInfo[] memInfo = type.GetMember(en.ToString());
if (memInfo != null && memInfo.Length > 0)
{
object[] attrs = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute),false);
if (attrs != null && attrs.Length > 0)
return ((DescriptionAttribute)attrs[0]).Description;
}
return en.ToString();
}
```
在这个例子中,我们通过Description特性为枚举常量指定了字符串表示形式,并通过GetDescription()方法获取枚举常量的描述信息。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)