更新
This commit is contained in:
@@ -45,8 +45,16 @@ public class UserService {
|
||||
* @param name
|
||||
* */
|
||||
public List<String> selectLabel(String name){
|
||||
String []stringList;
|
||||
stringList=userDao.selectLabel(name).split(";");
|
||||
String [] stringList;
|
||||
String label = userDao.selectLabel(name);
|
||||
if(label == null )
|
||||
{
|
||||
stringList="无搜索历史".split(";");
|
||||
}
|
||||
else{
|
||||
stringList=userDao.selectLabel(name).split(";");
|
||||
}
|
||||
|
||||
return Arrays.asList(stringList);
|
||||
}
|
||||
/**
|
||||
|
@@ -10,6 +10,8 @@ import jakarta.servlet.http.*;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@WebServlet("/selectUserLabel")
|
||||
public class selectUserLabelServlet extends HttpServlet {
|
||||
private UserService userService = new UserService();
|
||||
@@ -35,14 +37,22 @@ public class selectUserLabelServlet extends HttpServlet {
|
||||
PrintWriter writer = resp.getWriter();
|
||||
HttpSession session = req.getSession();
|
||||
userEntity userEntity=(userEntity)session.getAttribute("user");
|
||||
String jsonString = null;
|
||||
if(userEntity == null){
|
||||
setResultError("用户暂未登录", writer);
|
||||
}else{
|
||||
String name = userEntity.getUserName();
|
||||
String jsonString = JSONObject.toJSONString(userService.selectLabel(name));
|
||||
writer.println(jsonString);
|
||||
List<String> stringList = userService.selectLabel(name);
|
||||
if(stringList.get(0).equals("无搜索历史")){
|
||||
writer.println(jsonString);
|
||||
}
|
||||
else{
|
||||
jsonString = JSONObject.toJSONString(stringList);
|
||||
writer.println(jsonString);
|
||||
}
|
||||
|
||||
}
|
||||
// setResultOK("success",writer);
|
||||
|
||||
writer.close();
|
||||
|
||||
}
|
||||
|
@@ -60,6 +60,7 @@ public class userDetailServlet extends HttpServlet {
|
||||
dataMap.put("project",projectService.retProjectByUserId(id));
|
||||
jsonString = JSONObject.toJSONString(dataMap);
|
||||
writer.println(jsonString);
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user