我和春天有,JSP和jQuery中的Apache Tomcat 6 Web应用程序,一个jsp页面中有一个AJAX调用发送数据作出丝毫的jQuery,到春天的MultiActionController在我的后端的形式.
问题在于输入形式的UTF-8字符串.
我已经做了以下事情:
在我的HTML上:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" pageEncoding="utf-8"%>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head>
.
.
Run Code Online (Sandbox Code Playgroud)
在jquery ajax调用:
$.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8" });
$.ajax(
{
type: "GET",
url: "./saveData.action",
contentType: "charset=utf-8",
data: { name: $('#name').val(),...
Run Code Online (Sandbox Code Playgroud)
在tomcat server.xml上:
<Connector connectionTimeout="20000" port="8080" URIEncoding="UTF-8" protocol="HTTP/1.1" redirectPort="8443"/>
Run Code Online (Sandbox Code Playgroud)
在MultiActionController上
public ModelAndView saveData(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
{ …Run Code Online (Sandbox Code Playgroud) 我正在开发一个带有 spring 数据和 mongo db 数据库的后端。
我有以下课程
@Document
public class Place
{
@Id
private String id;
@GeoSpatialIndexed
private Double[] location;
private int[] category;
//gets and sets
}
Run Code Online (Sandbox Code Playgroud)
所以我想进行查询以获取具有所选类别的点附近的地方,所以我得到了这个:
public List<Place> getPlacesNear(Double[] location, int[] category){
NearQuery geoNear = NearQuery.near(location[0],location[1],Metrics.KILOMETERS).maxDistance(KM_DISTANCE);
Query categoryQuery = new Query(new Criteria("category").all(category));
geoNear.query(categoryQuery);
GeoResults<Place> geoNearResult = mongoTemplate.geoNear(geoNear, Place.class);
//return results
}
Run Code Online (Sandbox Code Playgroud)
但这没有返回任何结果,我知道查询。
db.place.find( { category: { $all: [ categoryID, categoryID2 ] } } );
Run Code Online (Sandbox Code Playgroud)
效果很好,geoNear 不是问题。
这是一个愚蠢的问题,但 Spring Data for Mongo 的文档和示例非常基础,任何帮助或良好教程或文档的链接都可能会有所帮助,谢谢!:)