81,122
社区成员




<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 -->
<context:component-scan base-package="com.spring.web.gameCenter.controller" />
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
</list>
</property>
</bean>
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 自动扫描(自动注入) -->
<mvc:resources location="WEB-INF/Back/" mapping="WEB-INF/Back/**" />
<mvc:resources location="/assets/" mapping="/assets/**" />
<!-- 视图渲染 jsp/freemaker/velocity-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 制定页面存放的路径 -->
<property name="prefix" value="/WEB-INF/Back/"></property>
<!-- 文件的后缀 -->
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding">
<value>UTF-8</value>
</property>
<property name="maxUploadSize">
<value>32505856</value><!-- 上传文件大小限制为31M,31*1024*1024 -->
</property>
<property name="maxInMemorySize">
<value>4096</value>
</property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<!-- Dubbo服务接口引用 -->
<import resource="classpath:spring/dubbo/dubbo-consumer.xml"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- 自动扫描controller包下的所有类,使其认为spring mvc的控制器 -->
<context:component-scan base-package="com.spring.web.gameCenter.controller" />
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" /><!-- json转换器 -->
</list>
</property>
</bean>
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 自动扫描(自动注入) -->
<mvc:resources location="WEB-INF/Back/" mapping="WEB-INF/Back/**" />
<mvc:resources location="/assets/" mapping="/assets/**" />
<!-- 视图渲染 jsp/freemaker/velocity-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 制定页面存放的路径 -->
<property name="prefix" value="/WEB-INF/Back/"></property>
<!-- 文件的后缀 -->
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding">
<value>UTF-8</value>
</property>
<property name="maxUploadSize">
<value>32505856</value><!-- 上传文件大小限制为31M,31*1024*1024 -->
</property>
<property name="maxInMemorySize">
<value>4096</value>
</property>
</bean>
</beans>
package com.spring.web.gameCenter.controller;
import java.io.IOException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@Controller
@RequestMapping("/adminController")
public class UserController {
@RequestMapping(value="index")
public String index() {
return "index";
}
@RequestMapping("index_v1")
public String index_v1() {
return "index_v1";
}
@RequestMapping("login")
public String login() {
return "login";
}
@RequestMapping("user")
public String user() {
return "user";
}
@RequestMapping("list")
@ResponseBody
public String list(String search,Integer offset,Integer limit,String sort,String order,String filter) throws IOException {
JSONObject jsonObject = new JSONObject(true);
return JSON.toJSONString(jsonObject);
}
@RequestMapping(value = "/testRestful/{id}", method = { RequestMethod.DELETE })
public String testRestfulDelete(Integer id) {
System.out.println("The value which the restful style url is DELETE :"
+ id);
return "success";
}
@RequestMapping(value = "/testRestful/{id}", method = { RequestMethod.PUT })
public String testRestfulPut(Integer id) {
System.out.println("The value which the restful style url is PUT :"
+ id);
return "success";
}
}
@Component
public class RequestMappingAppListener implements ApplicationListener<ContextRefreshedEvent>{
private static final Logger logger=LoggerFactory.getLogger(RequestMappingAppListener.class);
@override
public void onApplicationEvent(ContextRefreshedEvent event){
if(event.getApplicationContext().getDisplayName().equals("Root WebApplicationContext")){
return;
}
ApplicationContext ctx=event.getApplicationContext();
RequestMappingHandlerMapping rmhm=ctx.getBean(RequestMappingHandlerMapping.class);
if(rmhm==null) return;
Map<RequestMappingInfo,HandlerMethod> map=rmhm.getHandlerMethods();
for(Entry<RequestMapingInfo,HandlerMethod> e:map.entrySet()){
logger.error(e.getKey().toString()+","+e.getValue().toString());
}
}
}