67,549
社区成员




<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
2、想隐藏真实的路径,可以使用urlrewritefilter这个工具jar包,具体使用请参考官网:tuckey.org/urlrewrite/manual/4.0/index.html
3、Spring现在高版本可以使用RestController这个注解,该注解标记的类中所有的RequestMapping方法都将直接将结果写入response流中,如果要直接返回JSON格式的数据,做如下配置(我用的fastjson):备注(如果用Spring自带的JSON解析器,需要引入Jackson的相关jar包,不需要添加下面的配置也行)
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>