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

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

為什么輸入http://localhost:8080/seckill/list打不開列表界面

如果我把地址修改為http://localhost:8080/seckill/seckill/list即寫兩個(gè)seckill就可以打開詳細(xì)界面了。其實(shí)第一個(gè)seckill應(yīng)該是工程名,而第二個(gè)seckill才是RequestMapping定義的值,所以按照道理應(yīng)該是寫兩個(gè)seckill才能打開界面,為什么老師的演示只寫一個(gè)seckill就打開了界面呢?

正在回答

8 回答

這個(gè)問(wèn)題還是比較容易解決的,重點(diǎn)是在tomcat的配置文件server.xml上

新建一個(gè)tomcat,配置文件如下:

<Host?appBase="webapps"?autoDeploy="true"?name="localhost"?unpackWARs="true">
????<Valve?className="org.apache.catalina.valves.AccessLogValve"?directory="logs"?pattern="%h?%l?%u?%t?&quot;%r&quot;?%s?%b"?prefix="localhost_access_log"?suffix=".txt"?/>
</Host>

部署項(xiàng)目,如SecKill這個(gè)項(xiàng)目,此時(shí)配置文件更改成下面這樣的情況:

<Host?appBase="webapps"?autoDeploy="true"?name="localhost"?unpackWARs="true">
????<Valve?className="org.apache.catalina.valves.AccessLogValve"?directory="logs"?pattern="%h?%l?%u?%t?&quot;%r&quot;?%s?%b"?prefix="localhost_access_log"?suffix=".txt"/>
????<Context?docBase="SecKill"?path="/SecKill"?reloadable="true"?source="org.eclipse.jst.jee.server:SecKill"/>
</Host>

好吧,這個(gè)時(shí)候就很容看出來(lái)了,將我們的這個(gè)docBase的"SecKill"這個(gè)項(xiàng)目,對(duì)應(yīng)的映射成了path="/SecKill",如果想要項(xiàng)目開發(fā)時(shí)候不使用項(xiàng)目名,直接將path="",置為空,重啟項(xiàng)目,輸入路徑,OK,完成.

有不清楚的,歡迎互相討論.


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

taoy 提問(wèn)者

非常感謝!感覺(jué)應(yīng)該是這樣的。
2016-10-31 回復(fù) 有任何疑惑可以回復(fù)我~
<?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:p="http://www.springframework.org/schema/p"??
????xmlns:tx="http://www.springframework.org/schema/tx"??
????xmlns:mvc="http://www.springframework.org/schema/mvc"??
????xmlns:context="http://www.springframework.org/schema/context"??
????xsi:schemaLocation="http://www.springframework.org/schema/beans??
????????????????????????http://www.springframework.org/schema/beans/spring-beans.xsd??
????????????????????????http://www.springframework.org/schema/mvc??
????????????????????????http://www.springframework.org/schema/mvc/spring-mvc.xsd?
????????????????????????http://www.springframework.org/schema/tx?
????????????????????????http://www.springframework.org/schema/tx/spring-tx.xsd
????????????????????????http://www.springframework.org/schema/context??
????????????????????????http://www.springframework.org/schema/context/spring-context.xsd">
	<!--?配置springmvc?-->
	<!--?1.開啟?springmvc注解模式-->
	<!--?簡(jiǎn)化配置
		?(1)自動(dòng)注冊(cè)?DefaultAnnotationHandlerMapping,AnnotationMethodHandlerAdapter
		?(2)提供一系列:數(shù)據(jù)綁定,數(shù)字日期的format?@NumberFormat,@DateTimeFormat
			xml和json默認(rèn)讀寫配置
	?-->
	<mvc:annotation-driven/>
	
	<!--?
	?<bean?class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">?
????<property?name="contentType"?value="application/json"/>?
	</bean>?
	?-->
	<!--?2.servlet-mapping?映射路徑:“/”?-->
	<!--?靜態(tài)資源默認(rèn)servlet配置?
		(1):加入對(duì)靜態(tài)資源的處理:js,gif,png
		(2):允許使用"/"做整體映射
	-->
	
	<mvc:default-servlet-handler/>
	
	<!--?3.配置jsp?視圖解析器?ViewResolver?-->
	<bean?class="org.springframework.web.servlet.view.InternalResourceViewResolver">
			<property?name="viewClass"??value="org.springframework.web.servlet.view.JstlView"/>
			<property?name="prefix"?value="/WEB-INF/jsp/"/>
			<property?name="suffix"?value=".jsp"/>
	</bean>
	<!--?4:掃描web相關(guān)的bean?-->
	<context:component-scan?base-package="com.alan.seckil.web"/>
</beans>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1" metadata-complete="true">
<!-- 配置springmvc前端控制器 DispatcherServlet -->
? <servlet>
? <servlet-name>seckil-dispatcher</servlet-name>
? <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
? <!-- 配置springmvc需要加載的配置文件
? srping-dao.xml,spring-service.xml,spring-web.xml
? Mybatis->spring->springmvc
? -->
? <init-param>
? <param-name>contextConfigLocation</param-name>
? <param-value>classpath:/spring/sping-*.xml</param-value>
? </init-param>
? </servlet>
<servlet-mapping>
<servlet-name>seckil-dispatcher</servlet-name>
<!-- 默認(rèn)匹配所有的請(qǐng)求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

http://img1.sycdn.imooc.com//5a7eb9270001e75305590484.jpg

http://img1.sycdn.imooc.com//5a7eb9270001606c08550559.jpg

http://img1.sycdn.imooc.com//5a7eb9270001b31711090887.jpg

找不到映射怎么回事?

http://img1.sycdn.imooc.com//5a7eb98d0001099e13380868.jpg

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

老師應(yīng)該配置了tomcat的

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

web.xml

http://img1.sycdn.imooc.com//57e75e0000012b9004450130.jpg

spring-web.xml

http://img1.sycdn.imooc.com//57e75e450001449407360210.jpg

SeckillController.java

http://img1.sycdn.imooc.com//57e75e74000186c506540482.jpg

然后運(yùn)行后,瀏覽器打開的地址是這樣

http://img1.sycdn.imooc.com//57e75ec90001f4fa10110446.jpg

寫成http://localhost:8080/seckill/list?反而?打不開頁(yè)面

http://img1.sycdn.imooc.com//57e75eef000111c307380333.jpg

想問(wèn)下為什么,沒(méi)明白

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

nullundefine

我也是,解決了嗎哈哈?
2016-10-26 回復(fù) 有任何疑惑可以回復(fù)我~
#2

nullundefine

原來(lái)是/list前面寫成name了
2016-10-26 回復(fù) 有任何疑惑可以回復(fù)我~
#3

TaoHongBest

我也錯(cuò)在這了,lol
2018-09-16 回復(fù) 有任何疑惑可以回復(fù)我~

默認(rèn)是localhost:8080/{項(xiàng)目名}

老師在配置文件默認(rèn)就是/

所以就醬

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

這是個(gè)坑啊,

輸入U(xiǎn)RL:

http://localhost:8080/seckill

才能進(jìn)入 LIST界面,不知道是啥原因,誰(shuí)來(lái)指點(diǎn)一下

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

金小榮她老公

我的也是
2016-09-25 回復(fù) 有任何疑惑可以回復(fù)我~

@Controller
@RequestMapping("/seckill")
public class SeckillController {

??? private final Logger logger = LoggerFactory.getLogger(this.getClass());
??? @Autowired
??? private SeckillService seckillService;
?? ?
??? @RequestMapping(value="/list",method=RequestMethod.GET)
??? public String list(Model model) {
??????? model.addAttribute("list", seckillService.getSeckillList());
??????? return "list";
??? }

......

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

你Controller里面的RequestMapping是不是寫錯(cuò)了?

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

舉報(bào)

0/150
提交
取消

為什么輸入http://localhost:8080/seckill/list打不開列表界面

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

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

幫助反饋 APP下載

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

公眾號(hào)

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