介绍
这篇文章给大家分享的是有关怎么用Spring MVC创建网络应用的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
为了把Spring MVC运用到Web应用中,首先需要下载与操作系统对应的弹簧软件包,下载地址为https://repo.spring.io/libs-release-local/org/springframework/spring/
以下网址也提供了弹簧软件包的下载:
www.javathinker.net/javaweb.jsp
<强> 1.1,建立Spring MVC的环境强>
把弹簧软件包spring-framework-X.RELEASE-dist。zip解压到本地,把其中填词目录下的JAR文件考拷贝到Web应用的Web - inf/lib目录下。图1 - 1展示了基于春MVC的helloapp应用的目录结构。
学生。jsp使用了弹簧标签库中的标签。以下例程1 - 1是学生。jsp的代码。
例程1 - 1,student.jsp
& lt; % @page contentType =,“text/html; charset =, UTF-8", language =,“java", %比;=& lt; % @taglib  uri “http://www.springframework.org/tags/form",, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,prefix =,“form" %比; & lt; html> & lt;才能head> ,,,& lt; title> Spring MVC Sample & lt;才能/head> & lt;才能body> ,,,& lt; h3> Student Information ,,,& lt;形式:form method =,“POST", action =,“/helloapp/addStudent"比; ,,,,,& lt; table> ,,,,,,,& lt; tr> ,,,,,,,,,& lt; td> & lt;形式:label path =,“name"祝辞Name形式:label> & lt;/td> ,,,,,,,,,& lt; td> & lt;形式:input path =,“name",/祝辞& lt;/td> ,,,,,,,& lt;/tr> ,,,,,,,& lt; tr> ,,,,,,,,,& lt; td> & lt;形式:label path =,“age"祝辞Age形式:label> & lt;/td> ,,,,,,,,,& lt; td> & lt;形式:input path =,“age",/祝辞& lt;/td> ,,,,,,,& lt;/tr> ,,,,,,,& lt; tr> ,,,,,,,,,& lt; td> & lt;形式:label path =,“id"祝辞ID形式:label> & lt;/td> ,,,,,,,,,& lt; td> & lt;形式:input path =,“id",/祝辞& lt;/td> ,,,,,,,& lt;/tr> ,,,,,,,& lt; tr> ,,,,,,,,,& lt; td colspan =,“2“比; ,,,,,,,,,,,& lt; input type =,“submit", value =,“submit"/比; ,,,,,,,,,& lt;/td> ,,,,,,,& lt;/tr> ,,,,,& lt;/table>,, ,,,& lt;/形式:form> & lt;才能/body> & lt;/html>
以上student.jsp代码中的& lt;形式:form> & lt;形式:label>和& lt;形式:input>标签来自于春天标签库,用来生成HTML表单。
的结果。jsp负责显示客户端输入的学生信息,例程1 - 2是它的源代码。
例程1 - 2,result.jsp
& lt; % @page contentType =,“text/html; charset =, UTF-8", language =,“java", %比;=& lt; % @page  isELIgnored “false", %比;=& lt; % @taglib  uri “http://www.springframework.org/tags/form",, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,prefix =,“form" %比; & lt; html> & lt;才能head> ,,& lt; title> Spring MVC Sample & lt;才能/head> & lt;才能body> ,,,& lt; h3> Submitted Student Information null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null怎么用Spring MVC创建网络应用