/** * 聊天界面 */ @GetMapping("/index") public ModelAndView index(String username, String password, HttpServletRequest request) throws UnknownHostException { if (StringUtils.isEmpty(username)) { username = "匿名用户"; } ModelAndView mav = new ModelAndView("/chat"); mav.addObject("username", username); mav.addObject("webSocketUrl", "ws://"+InetAddress.getLocalHost().getHostAddress()+":"+request.getServerPort()+request.getContextPath()+"/chat"); return mav; }
@Override public Locale resolveLocale(HttpServletRequest request) { String l = request.getParameter("lg"); Locale locale = Locale.getDefault(); if(!StringUtils.isEmpty(l)){ String[] split = l.split("_"); locale = new Locale(split[0], split[1]); } return locale; }
@PostMapping(value ="/user/login") public String login(@RequestParam("username")String username, @RequestParam("password")String password, Map<String,Object> map, HttpSession session){ if(!StringUtils.isEmpty(username) && "123456".equals(password)){ //登录成功,防止重复提交 session.setAttribute("loginUser", username); return "redirect:/main.html"; }else{ map.put("msg", "用户名密码错误"); return "login"; } } }
@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) { String name = bindStatus.getExpression(); name = (name == null? "" : name); final String id = computeId(context, tag, name, false); final String value = ValueFormatterWrapper.getDisplayString(bindStatus.getValue(), bindStatus.getEditor(), true); String processedValue = RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "textarea"); if (!StringUtils.isEmpty(processedValue)) { final char c0 = processedValue.charAt(0); if (c0 == '\n') { processedValue = '\n' + processedValue; } else if (c0 == '\r' && processedValue.length() > 1 && processedValue.charAt(1) == '\n') { processedValue = "\r\n" + processedValue; } else if (c0 == '\r') { processedValue = '\r' + processedValue; } } StandardProcessorUtils.setAttribute(structureHandler, this.idAttributeDefinition, ID_ATTR_NAME, id); // No need to escape: this comes from an existing 'id' or from a token StandardProcessorUtils.setAttribute(structureHandler, this.nameAttributeDefinition, NAME_ATTR_NAME, name); // No need to escape: this is a java-valid token structureHandler.setBody((processedValue == null? "" : processedValue), false); }
modelMap.addAttribute("rankType", rankType); modelMap.addAttribute("compensatePoints", compensatePoints); if (isEmpty(timeSpan) && (fromDate != null || toDate != null || season != null || fromSeason != null || toSeason != null)) timeSpan = RankingsResource.CUSTOM; modelMap.addAttribute("timeSpan", timeSpan);
@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) { String name = bindStatus.getExpression(); name = (name == null? "" : name); final String id = computeId(context, tag, name, false); final String value = ValueFormatterWrapper.getDisplayString(bindStatus.getValue(), bindStatus.getEditor(), true); String processedValue = RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "textarea"); if (!StringUtils.isEmpty(processedValue)) { final char c0 = processedValue.charAt(0); if (c0 == '\n') { processedValue = '\n' + processedValue; } else if (c0 == '\r' && processedValue.length() > 1 && processedValue.charAt(1) == '\n') { processedValue = "\r\n" + processedValue; } else if (c0 == '\r') { processedValue = '\r' + processedValue; } } StandardProcessorUtils.setAttribute(structureHandler, this.idAttributeDefinition, ID_ATTR_NAME, id); // No need to escape: this comes from an existing 'id' or from a token StandardProcessorUtils.setAttribute(structureHandler, this.nameAttributeDefinition, NAME_ATTR_NAME, name); // No need to escape: this is a java-valid token structureHandler.setBody((processedValue == null? "" : processedValue), false); }
@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) { String name = bindStatus.getExpression(); name = (name == null? "" : name); final String id = computeId(context, tag, name, false); final String value = ValueFormatterWrapper.getDisplayString(bindStatus.getValue(), bindStatus.getEditor(), true); String processedValue = RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "textarea"); if (!StringUtils.isEmpty(processedValue)) { final char c0 = processedValue.charAt(0); if (c0 == '\n') { processedValue = '\n' + processedValue; } else if (c0 == '\r' && processedValue.length() > 1 && processedValue.charAt(1) == '\n') { processedValue = "\r\n" + processedValue; } else if (c0 == '\r') { processedValue = '\r' + processedValue; } } StandardProcessorUtils.setAttribute(structureHandler, this.idAttributeDefinition, ID_ATTR_NAME, id); // No need to escape: this comes from an existing 'id' or from a token StandardProcessorUtils.setAttribute(structureHandler, this.nameAttributeDefinition, NAME_ATTR_NAME, name); // No need to escape: this is a java-valid token structureHandler.setBody((processedValue == null? "" : processedValue), false); }
@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IThymeleafBindStatus bindStatus, final IElementTagStructureHandler structureHandler) { String name = bindStatus.getExpression(); name = (name == null? "" : name); final String id = computeId(context, tag, name, false); final String value = SpringValueFormatter.getDisplayString(bindStatus.getValue(), bindStatus.getEditor(), true); String processedValue = RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "textarea"); if (!StringUtils.isEmpty(processedValue)) { final char c0 = processedValue.charAt(0); if (c0 == '\n') { processedValue = '\n' + processedValue; } else if (c0 == '\r' && processedValue.length() > 1 && processedValue.charAt(1) == '\n') { processedValue = "\r\n" + processedValue; } else if (c0 == '\r') { processedValue = '\r' + processedValue; } } StandardProcessorUtils.setAttribute(structureHandler, this.idAttributeDefinition, ID_ATTR_NAME, id); // No need to escape: this comes from an existing 'id' or from a token StandardProcessorUtils.setAttribute(structureHandler, this.nameAttributeDefinition, NAME_ATTR_NAME, name); // No need to escape: this is a java-valid token structureHandler.setBody((processedValue == null? "" : processedValue), false); }
@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final BindStatus bindStatus, final IElementTagStructureHandler structureHandler) { String name = bindStatus.getExpression(); name = (name == null? "" : name); final String id = computeId(context, tag, name, false); final String value = ValueFormatterWrapper.getDisplayString(bindStatus.getValue(), bindStatus.getEditor(), true); String processedValue = RequestDataValueProcessorUtils.processFormFieldValue(context, name, value, "textarea"); if (!StringUtils.isEmpty(processedValue)) { final char c0 = processedValue.charAt(0); if (c0 == '\n') { processedValue = '\n' + processedValue; } else if (c0 == '\r' && processedValue.length() > 1 && processedValue.charAt(1) == '\n') { processedValue = "\r\n" + processedValue; } else if (c0 == '\r') { processedValue = '\r' + processedValue; } } StandardProcessorUtils.setAttribute(structureHandler, this.idAttributeDefinition, ID_ATTR_NAME, id); // No need to escape: this comes from an existing 'id' or from a token StandardProcessorUtils.setAttribute(structureHandler, this.nameAttributeDefinition, NAME_ATTR_NAME, name); // No need to escape: this is a java-valid token structureHandler.setBody((processedValue == null? "" : processedValue), false); }