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()
{
測試
}