第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

無法進(jìn)入$.get(seckill.URL.now(),{}, function(result){。。。},報(bào)404錯(cuò)誤

瀏覽器可以正常請求到j(luò)son數(shù)據(jù),但是$.get('/seckill/time/now',{},function(result){...}無法獲得json數(shù)據(jù),報(bào)404錯(cuò)誤

瀏覽器http請求頭和響應(yīng)頭:

Accept
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8????
Accept-Encoding????gzip,?deflate????
Accept-Language????zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3????
Cache-Control????max-age=0????
Connection????keep-alive????
Cookie????JSESSIONID=06FAA701426C4EC382C2E7F11F88779C????
DNT????1????
Host????localhost:8083????
Upgrade-Insecure-Requests????1????
User-Agent????Mozilla/5.0?(Windows?NT?6.2;?WOW64;?rv:53.0)?Gecko/20100101?Firefox/53.0

Content-Typeapplication/json;charset=UTF-8 ? ?
Date ? ?Tue, 09 May 2017 13:40:32 GMT ? ?
Server ? ?Apache-Coyote/1.1 ? ?
Transfer-Encoding ? ?chunked ? ?

$.get()的請求頭和響應(yīng)頭:

GET? http://localhost:8083/seckill/time/now

Host: localhost:8083
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: */*
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
X-Requested-With: XMLHttpRequest????? //網(wǎng)上查說這里不一樣,但不造怎么處理
Referer: http://localhost:8083/seckill-alpha/seckill/1009/detail
Cookie: killPhone=13812345678
DNT: 1
Connection: keep-alive


Server:?Apache-Coyote/1.1
Content-Type:?text/html;charset=utf-8
Content-Language:?en
Content-Length:?983
Date:?Tue,?09?May?2017?13:41:05?GMT

Controller:

????@RequestMapping(value?=?"/time/now",?method?=?{RequestMethod.GET,RequestMethod.POST},
????????????produces?=?{"application/json;charset=UTF-8"})
????@ResponseBody
????public??SeckillResult<Long>?time(){
????????Date?now?=?new?Date(System.currentTimeMillis());
????????logger.info("/time/now=====??",?now);
????????System.out.println("/time/now=====??"+now);
????????SeckillResult<Long>?result?=?new?SeckillResult<Long>(true,?now.getTime());
????????return?result;??????
????}

web.xml

<?xml?version="1.0"?encoding="UTF-8"?>
<web-app?xmlns="http://xmlns.jcp.org/xml/ns/javaee"
??xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
??xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
??????????????????????http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
??version="3.1"
??metadata-complete="true">
<display-name>secikill-webapp</display-name>
<!--修改servlet版本為3.1-->
<!--配置DispatcherServlet-->
<context-param>
????????<param-name>contextConfigLocation</param-name>
????????<param-value>classpath:spring/spring-*.xml</param-value>
</context-param>
<servlet>
????<servlet-name>servlet-dispatcher</servlet-name>
????<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
????<!--配置springmvc需要加載的配置文件
????????spring-dao.xml,spring-service.xml,?spring-web.xml
????????shunxumybatis->spring->springmvc
????-->
????<init-param>
????????<param-name>contextConfigLocation</param-name>
????????<param-value>classpath:*spring/spring-*.xml</param-value>
????</init-param>
????????<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
????<servlet-name>servlet-dispatcher</servlet-name>
????<!--默認(rèn)匹配所有請求,注意靜態(tài)資源-->
????<url-pattern>/</url-pattern>
</servlet-mapping>
????<welcome-file-list>
????????<welcome-file>/index.jsp</welcome-file>
????</welcome-file-list>
????<!--?配置SESSION超時(shí),單位是分鐘?-->
????<session-config>
????????<session-timeout>15</session-timeout>
????</session-config>
??<!--???編碼過濾器?-->
????<filter>
????????<filter-name>encodingFilter</filter-name>
????????<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
????????<async-supported>true</async-supported>
????????<init-param>
????????????<param-name>encoding</param-name>
????????????<param-value>UTF-8</param-value>
????????</init-param>
????</filter>
<!--?????<filter-mapping>
????????<filter-name>encodingFilter</filter-name>
????????<url-pattern>/*</url-pattern>
????</filter-mapping>?-->
????<!--?Spring監(jiān)聽器?-->
????<listener>
????????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
????</listener>
????<!--?防止Spring內(nèi)存溢出監(jiān)聽器?-->
????<listener>
????????<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
????</listener>
????
</web-app>


正在回答

3 回答

$.get('/seckill/time/now',{},function(result)

==》$.get('/seckill-alpha/seckill/time/now',{},function(result);

把項(xiàng)目名加上去試試..



1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕設(shè)計(jì)1656446

你這里的項(xiàng)目名指代不清楚,搞得我弄了好久,但是還是解決了。詳細(xì)的說法應(yīng)該是:$.get('/seckill-alpha/seckill/time/now',{},function(result);這里的seckill-alpha應(yīng)該指的是你的tomcat部署時(shí)的路徑,老師里的tomcat服務(wù)器部署的應(yīng)該默認(rèn)是空的,所以沒有問題,但是一般來說我們都會(huì)自己選擇部署的路徑。
2019-04-15 回復(fù) 有任何疑惑可以回復(fù)我~

或者這樣寫也可以的:

URL:?{
????now:?function?()?{
????????return?'/shopping/seckill/time/now';
????},
????exposer:?function?(seckillId)?{
????????return?'/shopping/seckill/'?+?seckillId?+?'/exposer';
????},
????execution:?function?(seckillId,?md5)?{
????????return?'/shopping/seckill/'?+?seckillId?+?'/'?+?md5?+?'/execution';
????}
},

我們把URL里的返回路徑統(tǒng)一設(shè)置一下就可以啦。同理,這里的/shopping是我的tomcat服務(wù)器的部署路徑。

1 回復(fù) 有任何疑惑可以回復(fù)我~
改成這樣就好啦:
這是我的修改后的代碼,這里的/shopping指的是tomcat的部署路徑。
$.get('/shopping/seckill/time/now',?{},?function?(result)
1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

無法進(jìn)入$.get(seckill.URL.now(),{}, function(result){。。。},報(bào)404錯(cuò)誤

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)