日期:2014-05-18 浏览次数:20864 次
<!-- 启动SpringMVC的注解功能,它会自动注册HandlerMapping、HandlerAdapter、ExceptionResolver的相关实例 -->
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<!-- 启动Spring的组件自动扫描机制 -->
<context:component-scan base-package="com.usoft.synusn.controller"></context:component-scan>
<!--通用视图解析器 -->
<bean id="viewResolverCommon"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="order" value="1" />
</bean>
<!-- SpringMVC的前端控制器 -->
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- <param-value>classpath*:applicationcontext-webmvc.xml,classpath*:applicationcontext-freemarker.xml</param-value> -->
<param-value>classpath*:applicationcontext-web.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<!-- 由SpringMVC拦截所有请求 -->
<url-pattern>/</url-pattern>
</servlet-mapping>
/**
* freemarker控制器
* @author
*
*/
@Controller
public class FreeMarkerControler {
@RequestMapping("/hello")
public String sayHello(ModelMap map) {
System.out.println("say Hello ……");
map.addAttribute("message", "Hello World,FreeMarker!");
return "test";
}
}