数据处理

来源:互联网 发布:强制视频软件多少钱 编辑:程序博客网 时间:2024/05/01 08:55

1.数据乱码问题

a.界面如果在URL后有中文传输,通过ajax,则需要encodeURI(encodeURI("xx")),在后台接收需要转换为 java.net.URLDecoder.decode(request.getParameter("xx"),"UTF-8");

b.如果是encodeURI("xx"),则后台接收需要转换为 new String(request.getParameter("xx").getBytes("ISO8859-1"), "UTF-8")


2.单元测试

import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

    @Resource
    private IxxService xxService; 
    
    @Before
    public void setUp() throws Exception
    {
        ApplicationContext context = new FileSystemXmlApplicationContext("/WebContent/WEB-INF/applicationContext.xml");
        xxService= (IxxService ) context.getBean("xxService");
    }

    @Test
    public void testDemo()
    {

测试

   }

0 0