最近開(kāi)始接觸SpringMVC這個(gè)框架,這個(gè)框架使用起來(lái)很方便,框架搭起來(lái)之后,寫(xiě)起代碼幾乎都是一個(gè)模式。當(dāng)然要走到這一步必須保證你的SpringMVC的相關(guān)配置都已經(jīng)完成,并且配置正確!
作為我的關(guān)于S平ringMVC的首篇博客,本篇博客主要說(shuō)名如何配置SpringMVC,并且可以使之正常的返回Bean實(shí)體,這里的bean實(shí)體一般返回到前端都是以Json字符串的形式返回的。
使用的開(kāi)發(fā)工具為eclipse,這個(gè)也是比較大眾化的開(kāi)發(fā)工具了,算的上是人人都會(huì)使用的了,只是熟練程度不一樣!
具體的配置如下:
web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.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" id="WebApp_ID" version="3.1"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <display-name>ReturnJsonDemo</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:dispatcher-servlet.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
網(wǎng)頁(yè)標(biāo)題:使用SpringMVC返回json字符串的實(shí)例講解-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://chinadenli.net/article14/djgjge.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、自適應(yīng)網(wǎng)站、微信小程序、靜態(tài)網(wǎng)站、軟件開(kāi)發(fā)、標(biāo)簽優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容