SpringMVC的相关配置:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<property name="contentType" value="text/html;charset=UTF-8"/>
</bean>
Controller:
@Controller
@RequestMapping("/search/")
public class SolrController {
@Autowired
private ItemSolrService service; @RequestMapping("list.html")
public String itemList(ItemSolr item,Model model){
Map<String,String> params = new HashMap<String,String>();
if(item != null){
params.put("q", "title:" + item.getTitle());
}
List<ItemSolr> itemList = service.queryByMap(params, ItemSolr.class);
model.addAttribute("itemList", itemList);
return "item_cat_list";
}
}
我想要的是跳转到页面将数据显示在html页面上,但实际上把整个jsp页面作为字符串响应了,如下图:有没有人知道原因?求帮助
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<property name="contentType" value="text/html;charset=UTF-8"/>
</bean>
Controller:
@Controller
@RequestMapping("/search/")
public class SolrController {
@Autowired
private ItemSolrService service; @RequestMapping("list.html")
public String itemList(ItemSolr item,Model model){
Map<String,String> params = new HashMap<String,String>();
if(item != null){
params.put("q", "title:" + item.getTitle());
}
List<ItemSolr> itemList = service.queryByMap(params, ItemSolr.class);
model.addAttribute("itemList", itemList);
return "item_cat_list";
}
}
我想要的是跳转到页面将数据显示在html页面上,但实际上把整个jsp页面作为字符串响应了,如下图:有没有人知道原因?求帮助
解决方案 »
- tomcat6.0发布遇到的错误。
- Lucene 对索引进行检索方式:TermQuery 和 QueryParser
- 一个关于db2存储jbpm表的问题,急!!!
- 配置SVN的Web客户端WebClient for SVN(SVNWebClient)
- jsp生成xml文件时, 会在文件头产生的空白行
- 求助:jspsmartupload 下载文件时关于中文文件名的问题
- tomcat 与 jdk 问题,急等到
- 高分求教 应用服务器问题
- 求助:那个经典的HelloWorld的应用程序(含全部代码)怎么部署?
- Java 如何获取注释
- 多个Html页面 多个表单
- ognl.MethodFailedException: Method "list" failed for object com.hyq.Action.Emplo
<servlet>
<servlet-name>springmvc-web</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 指定SpringMVC配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc-web</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
将<url-pattern>/*</url-pattern> 改为<url-pattern>/</url-pattern>就好了
参考http://blog.csdn.net/kaiwii/article/details/7899941