package cn.netbuffer.ssmbootstrap_table.controller;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.alibaba.fastjson.JSONObject;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Binarizer;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
import com.google.zxing.EncodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.client.j2se.MatrixToImageConfig;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import cn.netbuffer.ssmbootstrap_table.annotation.Token;
import cn.netbuffer.ssmbootstrap_table.model.Address;
import cn.netbuffer.ssmbootstrap_table.model.ExtendUser;
import cn.netbuffer.ssmbootstrap_table.model.User;
import cn.netbuffer.ssmbootstrap_table.util.AjaxUtils;
import eu.bitwalker.useragentutils.UserAgent;
@Controller
@RequestMapping("/test")
@SessionAttributes("name")
public class TestController {
private static final Logger LOG=LoggerFactory.getLogger(TestController.class);
private Logger loggerAccess = LoggerFactory.getLogger("access");
// private Logger logger = LoggerFactory.getLogger(this.getClass());
private Logger logger = loggerAccess;
@Autowired
private ApplicationContext applicationContext;
@Resource
private Properties configProperties;
@Value("#{configProperties['url2']}")
private String url;
@Value("#{configProperties['mysql.connectTime']}")
private Integer connectTime;
@Autowired
private CookieLocaleResolver cookieResolver;
//锁
private Lock lock=new ReentrantLock();
//注入静态属性值
private static String JDBCURL;
//注入方法
@Value("#{configProperties['jdbc.url']}")
public void setJdbcUrl(String url) {
JDBCURL = url;
}
//@RequestMapping不写value会默认映射类上的访问路径"/test"
@RequestMapping(method=RequestMethod.GET)
public @ResponseBody String getTest() {
LOG.debug("GET to /test");
return "GET to /test";
}
@RequestMapping(method=RequestMethod.POST)
public @ResponseBody String postTest() {
LOG.debug("POST to /test");
return "POST to /test";
}
@RequestMapping(value = {"/getJdbcUrl" })
public @ResponseBody String getJdbcUrl() {
logger.debug("静态属性值:{}",JDBCURL);
return JDBCURL;
}
@RequestMapping(value = {"/getbean/{name}" })
public @ResponseBody Object getbean(@PathVariable("name") String name) {
return applicationContext.getBean(name);
}
@RequestMapping(value = {"/{id}", "/index/{id}" })
public String index(@PathVariable("id") int id, ModelMap m) {
logger.debug("template id:{}", id);
m.addAttribute("uri", id);
m.addAttribute("showTime", System.currentTimeMillis() / 1000);
m.addAttribute("test",id);
return "test";
}
@RequestMapping(value = { "/getconfig" })
public Object getConfig() {
return JSONObject.toJSON(configProperties);
}
@RequestMapping(value = { "/geturl" })
public @ResponseBody String getUrl() {
logger.debug("url:{}", url);
return url;
}
@RequestMapping(value = { "/getConnectTime" })
public @ResponseBody Integer getConnectTime() {
logger.debug("connectTime:{}", connectTime);
return connectTime;
}
/**
* 直接写响应,会使用FastJsonHttpMessageConverter作json转换 访问路径会直接以json输出
*
* @return
*/
@RequestMapping(value = { "/getobj" })
public @ResponseBody Map<String, Object> getobj() {
Map<String, Object> res = new HashMap<String, Object>();
res.put("key1", "v1");
res.put("key2", "v2");
return res;
}
@RequestMapping(value = { "/setSessionAttr" })
public @ResponseBody String setSessionAttr(ModelMap m) {
logger.debug("setSessionAttr");
// 会被放到session中
m.put("name", "this is name's value");
return "success";
}
/**
* 返回本地化信息
*
* @param locale
* @return
* @author genie
* @date 2016年6月13日 下午1:54:11
*/
@RequestMapping(value = { "/locale" })
public @ResponseBody String locale(Locale locale) {
logger.debug("locale:{}", locale);
return locale.toString();
}
@RequestMapping("/lang")
@ResponseBody
public String lang(@RequestParam(defaultValue="zh",required=false,value="lang")String langType, HttpServletRequest request, HttpServletResponse response) {
if (langType.equals("zh")) {
Locale locale = new Locale("zh", "CN");
// request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME,
// locale);
cookieResolver.setLocale(request, response, locale);
} else if (langType.equals("en")) {
Locale locale = new Locale("en", "US");
// request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME,
// locale);
cookieResolver.setLocale(request, response, locale);
} else
cookieResolver.setLocale(request, response, LocaleContextHolder.getLocale());
// request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME,
// LocaleContextHolder.getLocale());
return langType;
}
@Token(save=true,tokenname="testformtoken")
@RequestMapping(value="/form",method=RequestMethod.GET)
public String getform(){
logger.debug("test get form ");
return "user/add";
}
@Token(remove=true,tokenname="testformtoken",failuri="/user/error.jsp")
@RequestMapping(value="/form",method=RequestMethod.POST)
public String postform(@Valid User u){
// ,BindingResult result
logger.debug("test post form:{}",u);
// if(result.hasErrors()){
// logger.info("校验user出错:"+ToStringBuilder.reflectionToString(result));
// throw new RuntimeException("请填写正确的用户信息");
// }
// return "redirect:/register-success.html";
//forward请求导致表单重复提交问题
return "user/success";
}
/**
* 直接返回json数据 ,produces={"application/json"}
*/
@RequestMapping(value={"/uri"},method=RequestMethod.GET,headers={"Accept=a
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一款基于Spring、SpringMVC、MyBatis和Bootstrap框架开发的SSM Bootstrap Table设计源码。项目结构包含379个文件,涉及136个Java源文件、78个JavaScript文件、46个PNG图片、19个CSS样式文件、18个JSP页面、16个XML配置文件、16个GIF图片、10个HTML文件、9个属性文件以及5个JPG图片。该项目作为Gitee上netbuffer/jfinal-bootstrap-table的姊妹项目,旨在提供一套完整且高效的Web应用解决方案。
资源推荐
资源详情
资源评论































收起资源包目录





































































































共 377 条
- 1
- 2
- 3
- 4
资源评论


wjs2024
- 粉丝: 3431
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 科技平台如何借助AI+数智应用解决资源丰富度和可持续发展问题?.docx
- 科技平台如何借助AI+数智应用解决资源匮乏与服务低效的问题?.docx
- 科技平台如何借助AI+数智应用实现可持续发展,避免陷入“资源有余而活力不足”的困境?.docx
- 科技平台如何利用AI+数智应用工具提升服务价值和市场竞争力?.docx
- 科技平台如何通过AI+数智应用解决资源整合难题?.docx
- 科技平台运营模式创新有哪些AI+数智应用关键要素?.docx
- 科技市场化过程中,如何通过AI+数智应用有效整合资源以提升平台竞争力?.docx
- 科技市场化中,如何通过AI+数智应用应对技术转移过程中的挑战?.docx
- 科技项目创新管理中如何通过AI+数智应用高效整合多维度资源,解决平台资源匮乏问题?.docx
- 科技资源管理平台的三大核心问题是什么?如何通过AI+数智应用工具有效解决?.docx
- 科技资源管理平台如何通过AI+数智应用实现可持续发展?.docx
- 面对复杂的技术转移服务需求,如何通过AI+数智应用构建更智能高效的服务体系?.docx
- 面对技术引进合作分析的需求,AI+数智应用科技创新平台应如何高效应对?.docx
- 面对科技服务平台服务效能不足的问题,如何借助AI+数智应用科技创新助力提升服务专业性和效率?.docx
- 企业科技创新服务平台如何通过AI+数智应用保障服务质量与专业性?.docx
- 企业科技创新服务平台如何借助AI+数智应用解决科技资源匮乏与信息不对称问题?.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
