SPRINGMVC (b): HelloWorld

Source: Internet
Author: User

Preparation conditions:

STS (Eclipse with spring-related tools integrated)


    1. Add the jar package.

      Create a new Dynamic Web project in Eclipse. Select Tomcat 7.0 and add the following jar packages under the Webcontent-->web-inf-->lib directory.








Additional Commons-logging-1.2.jar files are also required.

Add Dispatcherservlet related content in Web. XML (using the shortcut key alt+/, in the pop-up drop-down bar, select #dispatcherservlet). The contents of the Web. XML configuration file can refer to the following: <?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_3_0.xsd " version=" 3.0 " >  <display-name>HelloWorld</display-name>  <welcome-file-list>     <welcome-file>index.html</welcome-file>    <welcome-file >index.htm</welcome-file>    <welcome-file>index.jsp</welcome-file>     <welcome-file>default.html</welcome-file>    < welcome-file>default.htm</welcome-file>    <welcome-file>default.jsp</ Welcome-file>  </welcome-file-list>  <!-- the front controller of this spring web application,  responsible for handling all application requests --><servlet> <servlet-name>springDispatcherServlet</servlet-name><servlet-class> org.springframework.web.servlet.dispatcherservlet</servlet-class><!--  Configure an initialization parameter for the Dispathcerservlet, set the name and location of the configuration file  --><init-param><param-name>contextconfiglocation </param-name><param-value>classpath:springmvc.xml</param-value></init-param>< load-on-startup>1</load-on-startup></servlet><!-- map all requests to  the DispatcherServlet for handling --><servlet-mapping><servlet-name> Springdispatcherservlet</servlet-name><url-pattern>/</url-pattern></servlet-mapping> </web-app> Add springmvc config file. Write the requested processor. Write a view.

Springmvc (b): HelloWorld

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.