Skip to content

Commit 5c798e3

Browse files
committed
feat: 测试web
1 parent 1e9e8f4 commit 5c798e3

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.springframework.web;
2+
3+
import org.springframework.stereotype.Controller;
4+
import org.springframework.ui.Model;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestParam;
7+
8+
@Controller
9+
public class HelloController {
10+
11+
@GetMapping("/hello")
12+
public String hello(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
13+
model.addAttribute("name", name);
14+
return "hello";
15+
}
16+
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<beans xmlns="http://www.springframework.org/schema/beans"
2+
xmlns:context="http://www.springframework.org/schema/context"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans
5+
http://www.springframework.org/schema/beans/spring-beans-5.3.xsd
6+
http://www.springframework.org/schema/context
7+
http://www.springframework.org/schema/context/spring-context-5.3.xsd">
8+
9+
<context:component-scan base-package="org.springframework.web"/>
10+
11+
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
12+
<property name="prefix" value="/WEB-INF/jsp/"/>
13+
<property name="suffix" value=".jsp"/>
14+
</bean>
15+
16+
</beans>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<web-app>
2+
<display-name>MyWebApp</display-name>
3+
<servlet>
4+
<servlet-name>spring</servlet-name>
5+
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
6+
<init-param>
7+
<param-name>contextConfigLocation</param-name>
8+
<param-value>/WEB-INF/spring-servlet.xml</param-value>
9+
</init-param>
10+
<load-on-startup>1</load-on-startup>
11+
</servlet>
12+
<servlet-mapping>
13+
<servlet-name>spring</servlet-name>
14+
<url-pattern>/</url-pattern>
15+
</servlet-mapping>
16+
</web-app>

0 commit comments

Comments
 (0)