Spring Framework: различия между версиями

Содержимое удалено Содержимое добавлено
Новая страница: «= Простой проект = <source lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.spr…»
 
Нет описания правки
Строка 1:
= Простой проект =
Файл dispatcher-servlet.xml
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
xmlns:xsi="http://www.springframeworkw3.org/dtd2001/springXMLSchema-beans.dtdinstance">
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
 
<context:component-scan base-package="org.app.controller" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
 
 
</beans>
</source>
 
Контроллер UserController.java
<source lang="java">
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.app.controller;
 
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
/**
*
* @author alec
*/
@Controller
public class UserController {
@RequestMapping(value="/index.htm", method=RequestMethod.GET)
public String userIndex(Model model) {
//model.addAttribute(new User());
return "index";
}
@RequestMapping(value="/user/create.htm", method=RequestMethod.GET)
public String userCreate(Model model) {
return "usercreate";
}
}
 
</source>