失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > HTTP Status 406 -with characteristics not acceptable according to the request accept headers.

HTTP Status 406 -with characteristics not acceptable according to the request accept headers.

时间:2019-11-16 17:53:07

相关推荐

HTTP Status 406 -with characteristics not acceptable according to the request accept headers.

贴上完整错误信息:

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request “accept” headers.

1、在练习springmvc中int返回值类型的时候,访问项目遇到上述问题

index.jsp代码:

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><base href="<%=basePath%>"><title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--><script type="text/javascript" src="js/jquery.js"></script><script type="text/javascript">$(function(){var url = "${pageContext.request.contextPath}/intDemo";var sendData = null;$.post(url,sendData,function(resultData){console.log(resultData);});});</script></head><body>This is my JSP page. <br></body></html>

测试页面:

@Controllerpublic class PersonController {//int//http://localhost:8080/day11exe/intDemo@RequestMapping("intDemo")@ResponseBodypublic int intDemo(){System.out.println("intDemo--------------");return 88;}}

2、检查后发现springmvc-servlet.xml主配置文件少了静态资源放行的代码

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="/schema/beans"xmlns:xsi="/2001/XMLSchema-instance"xmlns:context="/schema/context"xmlns:mvc="/schema/mvc"xsi:schemaLocation="/schema/beans/schema/beans/spring-beans-4.3.xsd/schema/context/schema/context/spring-context-4.3.xsd/schema/mvc/schema/mvc/spring-mvc-4.3.xsd"><context:component-scan base-package="com.fsx.*"></context:component-scan><!-- 静态资源放行springmvc005/js/jquery.js 静态资源 locationmapping--><mvc:annotation-driven></mvc:annotation-driven><mvc:resources location="/js/" mapping="/js/**"></mvc:resources><!--视图解析器 --><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property><property name="prefix" value="/"></property><property name="suffix" value=".jsp"></property></bean></beans>

3、结果图

如果觉得《HTTP Status 406 -with characteristics not acceptable according to the request accept headers.》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。