国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

springMVC框架(一)HelloWold

2019-11-08 02:20:55
字體:
供稿:網(wǎng)友

公司使用的框架是jfinal,開發(fā)工具用的NetBeans,最近開始倒騰sPRingMVC了,就寫了下Helloworld,中間還遇到了一個坑嗲的問題,那就是No mapping found for HTTP request with URI [/springmvc-01/] in DispatcherServlet with name 'dispatcherServlet'。

在網(wǎng)上找了很多資料,web.xml中配置的錯誤,<url-pattern>/*</url-pattern>改為/,把*去掉,但是很明顯,我用的就是/。

后來挨個看配置文件也沒有問題,項目啟動的時候就是訪問不到index.jsp

       仔細看了下,我的index.jsp放到了WEB-INF下面了,所有才訪問不到的,index.jsp是和WEB-INF同級的。估計這個超低級的錯誤,只有我犯過吧。。

--------------------------------------------------------------------------------------------------------------------------------------------------

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"	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"	id="WebApp_ID" version="2.5">	<!-- 配置 DispatcherServlet -->	<servlet>		<servlet-name>dispatcherServlet</servlet-name>			<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>		<init-param>			<param-name>contextConfigLocation</param-name>			<param-value>classpath:dispatcherServlet-servlet.xml</param-value>		</init-param>	<load-on-startup>1</load-on-startup>	</servlet>	<servlet-mapping>		<servlet-name>dispatcherServlet</servlet-name>		<url-pattern>/</url-pattern>	</servlet-mapping></web-app>dispatcherServlet-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"	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-4.0.xsd		http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">	<!-- 配置自定掃描的包 -->	<context:component-scan base-package="com.kevin.controller"></context:component-scan>	<!-- 配置視圖解析器: 如何把 handler 方法返回值解析為實際的物理視圖 -->	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">		<property name="prefix" value="/WEB-INF/views/"></property>		<property name="suffix" value=".jsp"></property>	</bean>	<!-- 在實際開發(fā)中通常都需配置 mvc:annotation-driven 標簽 -->	<mvc:annotation-driven></mvc:annotation-driven></beans>HelloWorld.class

package com.kevin.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@Controllerpublic class HelloWorld {	/**	 * 使用@RequestMapping來映射URL	 * 返回值會被視圖解析器解析成物理試圖,試圖解析器會做如下解析	 * prefix+return值+后綴,得到實際視圖,然后做轉(zhuǎn)發(fā)操作	 * @return	 */	@RequestMapping("/helloworld")	public String hello(){		System.out.println("HelloWorld");		return "success";	}}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 茂名市| 新蔡县| 葵青区| 萨迦县| 玉林市| 长治市| 军事| 宁陵县| 游戏| 乌拉特中旗| 迁西县| 咸丰县| 乌兰县| 宁河县| 宁夏| 商城县| 汤原县| 翁牛特旗| 张家川| 邓州市| 马公市| 宁都县| 新宾| 九龙城区| 自贡市| 安龙县| 木兰县| 阳东县| 江安县| 若羌县| 花莲市| 湖南省| 靖远县| 兖州市| 金湖县| 布拖县| 吴旗县| 道真| 建平县| 宜兴市| 海安县|