开发者社区> 我是温浩然> 正文

Could not resolve view with name 'pcir/del' in servlet with name 'forum'

简介: 惯例: 我是温浩然: springMVC中遇到的错误, 除了查询,只要是对数据库进行修改的操作,总是成功操作数据到数据库,然后,控制台报错。 就是用这一套东西,来进行一系列操作, 整个系统架构是,springframework+JDBC+tiles. 先贴一段代码,追踪错误的时候,追踪到这里 getMasterTemplate().update(new PreparedSt
+关注继续查看

惯例:

我是温浩然:

springMVC中遇到的错误,

除了查询,只要是对数据库进行修改的操作,总是成功操作数据到数据库,然后,控制台报错。

就是用这一套东西,来进行一系列操作,

整个系统架构是,springframework+JDBC+tiles.

先贴一段代码,追踪错误的时候,追踪到这里

getMasterTemplate().update(new PreparedStatementCreator() {

			@Override
			public java.sql.PreparedStatement createPreparedStatement(
					java.sql.Connection con) throws SQLException {
				PreparedStatement ps = con.prepareStatement(sql);
				int i = 0;
				ps.setString(++i, circle.getName());
				ps.setLong(++i, circle.getCreateTime());
				return ps;
			}
		});
这里的,

<span style="font-family: Arial, Helvetica, sans-serif;">getMasterTemplate</span>
是另一段代码,我也贴出来

@Resource(name = "forumTemplate")
    private JdbcTemplate masterTemplate;
    

    protected JdbcTemplate getMasterTemplate() {
        return masterTemplate;
    }

要是你问我@resource是什么东西,我只能告诉你,自己去百度spring注解。

然后,我把controller贴出来

@RequestMapping(value = "/del")
    public RetrunValue delCircle(@RequestBody Map<String,Object> map) {
		
		long circleId = Long.parseLong( map.get("id").toString());
		try {
			circleService.delete(circleId);
		} catch (Exception e) {
			resultCode=ResultCode.NOT_EXIST;
		}
		return new RetrunValue(resultCode.getCode());
	}

然后就报错了,报错信息如下:

严重: Servlet.service() for servlet [forum] in context with path [/forum] threw exception [Could not resolve view with name 'pcir/del' in servlet with name 'forum'] with root cause
javax.servlet.ServletException: Could not resolve view with name 'pcir/del' in servlet with name 'forum'
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1190)
	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


错误日志好多,是不?

而且还没提示是咱们写的代码哪个地方有错。

然后,用debug又追踪不到真正的错误

然后,直觉告诉我,肯定是controller中,什么地方少引用了什么东西。

因为,无论我进行什么操作,总是成功操作到数据库的,然后控制台打印错误。

然后,找到了这个

http://liyanjie918.blog.163.com/blog/static/20227290201311253503695/

说的比较含糊,我这里属于第二种原因,方法中,加入了一个注解。@ResponseBody

然后就可以了,成功的代码如下:


@RequestMapping(value = "/del")
    public <span style="color: rgb(216, 130, 109); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">@ResponseBody</span> RetrunValue delCircle(@RequestBody Map<String,Object> map) {
		
		long circleId = Long.parseLong( map.get("id").toString());
		try {
			circleService.delete(circleId);
		} catch (Exception e) {
			resultCode=ResultCode.NOT_EXIST;
		}
		return new RetrunValue(resultCode.getCode());
	}


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
springMvc33-estful的delete
springMvc33-estful的delete
39 0
vue-watch报错[[Vue warn]: Method “watch“ has type “object“ in the component definition. Did you refer]
[Vue warn]: Method “watch” has type “object” in the component definition. Did you reference the function correctly?
606 0
javax.servlet.ServletException: Circular view path [hello]: would dispatch back to the current handl
javax.servlet.ServletException: Circular view path [hello]: would dispatch back to the current handl
406 0
How to render S4 Code List extension field into CRM WebUI product search view
This question is asked by Wade. Suppose I have created one extension field in S4 with type CodeList which contains all possible queue type supported by JDK. This extension field must be exposed to CRM Product Search WebUI. POC is done in X3C/504:
46 0
SAP Spartacus lazy load 的一个例子 - User Module
SAP Spartacus lazy load 的一个例子 - User Module
46 0
How is correct index.html served by ui5 handler from BSP repository
Created by Jerry Wang, last modified on Aug 26, 2015 This wiki explains the process how the index.html of Fiori application is served by UI5 resource handler. The url of index looks like below: https://:/sap/bc/ui5_ui5/sap/zfiori150320/index.html?sap-client=001&sap-ui-language=EN&sap-ui-appcache=fal
43 0
How to create CDS view to return Service order item detail data
You are asked to create a CDS view which must return the following information of Service order line item.
70 0
Could not resolve view with name 'xxx' in servlet with name dispatcherServlet
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/80336983 ...
6401 0
Circular view path [addKnowledge]: would dispatch back to the current handler URL
报错日志: {"timestamp":1526565246776,"status":500,"error":"Internal Server Error","exception":"javax.
3430 0
Circular view path xxx would dispatch back to the current handler URL
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/79700275 ...
5296 0
+关注
我是温浩然
今天的菜鸟,未来的大牛
文章
问答
视频
文章排行榜
最热
最新
相关电子书
更多
Apache Wicket User Guide - Ref
立即下载
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载