spring 3.1.1
jquery 1.8.0
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>biservice</display-name>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>json</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>json</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.ft.bi.controller" />
<context:annotation-config />
<mvc:annotation-driven />
</beans>
Controller
@Controller
public class BiController {
@Autowired
private BiService biService;
@RequestMapping(value = "/search")
@ResponseBody
public List<UvModel> getAnalysisDatas(@RequestParam String start,
@RequestParam String end, @RequestParam int prjid,
@RequestParam int ty) {
return biService.getUvModels(start, end, prjid, ty);
}
ajax代码
$.ajax({
url : 'http://localhost:8080/biservice/search?start=2013-03-01&end=2013-03-02&prjid=333&ty=1',
dataType : 'json',
success : function(data) {
alert(data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert("Issue fetching the JSON: "
+ textStatus + " "
+ errorThrown + " !");
}
});
}
主要问题:
1、在浏览器访问 如果没有插件,会下载json内容
2、ajax访问 alert error no Transport
3、firebug查看ajax请求状态为200,但没有响应项和JSON项
4、直接用firefox访问、firebug查看
响应 内为返回数据,JSON内为放回数据
相关推荐
spring 3.1 mvc sample Spring 3.1的最新例子
演示spring3.1 mvc一个入门的例子
Spring 3.1 jar包Spring 3.1 jar包Spring 3.1 jar包Spring 3.1 jar包Spring 3.1 jar包
springMVC3.1 +mybatis3.1集成,包括事务,jqueryEasyUI分页,json,数据库连接池等。环境使用eclipse4.3+maven3.0.5+tomcat7
NULL 博文链接:https://chen-rojer-gmail-com.iteye.com/blog/1038317
spring mvc 常用开发框架 jar包 提高开发效率 降低开发难度
spring4 mvc 配置json 所需要的依赖jar包很全
Spring MVC 3.0与Jquery整合示例项目
NULL 博文链接:https://qisehua.iteye.com/blog/1729015
Spring 3.1的 源码,在IDE中关联即可查看框架源码
springmvc jquery ajax json 异步传递数据 springmvc异步传递请求 已包含全部源代码实现 把jar包放入 然后新建文件 配置xml !!!!! 全部资源
spring3.1完整包
spring3.1官方所有的jar包 org.springframework.aop-3.1.RELEASE.jar org.springframework.asm-3.1.RELEASE.jar org.springframework.aspects-3.1.RELEASE.jar org.springframework.beans-3.1.RELEASE.jar org....
Ajax With Spring 3. Eclipse 工程,包含Web所需要的 所有jar包。 1> ajax 请求。 2> spring 3注解使用 3> mvc:annotation
spring3.1最新版本的开发宝典,内容详解!
Spring3.1AOP简单例子,需要的jar包分开上传了
NULL 博文链接:https://liukai.iteye.com/blog/975103
Spring 3.1倚赖的外部jar包汇总
Spring MVC跟jQuery和Twitter Bootstrap的结合
spring3.1需要的jar包,自身实验过,调试过程序可以正常运行