In fact, and mvc visual studio almost, that is, different languages and platforms - - because before school in Australia is visual studio of mvc, so there would control what.
mvc: model, view, controller architecture. The data packets into the database and then enity object-oriented type processing, contoller control view is displayed.
Platform: idea
Background Language: java
1. Create a spring mvc project
2. project name, project path
I had done a job with the idea, it was the first time directly on the workspace (this is my own folder built) in, so built a new store this.
3. Modify the web.xml
3.1 Open web.xml
3.2 modify <servlet-mapping>, this is to configure incident response, determine what kind of reception the request will be processed.
The intercept form form
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.form</url-pattern> </servlet-mapping>
Modified to intercept all requests
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
4.修改dispatcher-servlet.xml
4.1 打开dispatcher-servlet.xml
4.2 修改配置文件<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <props> <!-- /hello 路径的请求交给 id 为 helloController 的控制器处理--> <prop key="/hello">helloController</prop> </props> </property> </bean> <bean id="helloController" class="controller.HelloController"></bean> </beans>
在beans里面加了2个bean
bean是用来进行实例化的(大概?),可以帮助对数据库进行增删改查。在visual studio中使用code first是自动生成的。
5 创建HellloContoller类
在src下创建pakage controller,然后创建class HelloController,这个controller表明他是控制hello页面的显示。
visual studio中会在创建数据库后可以自动创建对应model,然后自动创建controller和view。
发现没装tom cat,先研究一下- -