spirng 乱码

    xiaoxiao2021-12-12  3

    spring dao  在jsp文件跳转过程中乱码的解决方法:

    <%@ page language="java" contentType="text/html; charset=UTF-8"     pageEncoding="UTF-8"%> <%@ page import="package083.*" %> <%@ page import="org.springframework.context.ApplicationContext" %> <%@ page import="org.springframework.core.io.*" %> <%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <link rel="stylesheet" type="text/css" href="css/productType.css"> <link rel="stylesheet" type="text/css" href="css/productList.css"/> <link rel="stylesheet" type="text/css" href="css/dangdang.css" /> <link rel="stylesheet" type="text/css" href="css/public_mall.css"> <link rel="stylesheet" type="text/css" href="css/common.css"> <link rel="stylesheet" type="text/css" href="css/login.css"> <link rel="stylesheet" type="text/css" href="css/user.css"> </head> <body> <%          request.setCharacterEncoding("utf-8");    //注意设置得到的参数格式         response.setCharacterEncoding("utf-8");  //注意设置返回客户端浏览器的参数格式 String code=request.getParameter("goodsCode");                 // String test=new String(request.getParameter("goodsName"));       String name=new String(request.getParameter("goodsName").getBytes("utf-8"),"utf-8");    //  String name = new String(request.getParameter("goodsName").getBytes("ISO-8859-1"),"GB18030"); String type= request.getParameter("goodsCategory"); String price=request.getParameter("goodsPrice"); String newPrice=request.getParameter("goodsPreferentialPrice"); String number=request.getParameter("goodsStockNumber"); String address=request.getParameter("goodsImageAddress"); GoodsInfo goods=new GoodsInfo(); goods.setGoodsCode(code); goods.setGoodsName(name); goods.setGoodsCategory(Integer.parseInt(type)); goods.setGoodsPrice(Double.valueOf(price)); goods.setGoodsPreferentialPrice(Double.valueOf(newPrice)); goods.setGoodsStockNumber(Integer.valueOf(number));   /* goods.setGoodsImageAddress(address); */         ApplicationContext factory  = new ClassPathXmlApplicationContext("applicationContext.xml");         GoodsInfoDao goodsdao = (GoodsInfoDao)factory.getBean("myDao"); goodsdao.addGoods(goods); out.print("成功新增商品数据"); %> </body> </html>

    转载请注明原文地址: https://ju.6miu.com/read-900229.html

    最新回复(0)