我是 sakai 开发的新手,我选择使用 spring mvc。该工具构建良好,但我得到 No bean named 'org.sakaiproject.logic.SakaiProxy' is defined 错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/index.htm' defined in ServletContext resource [/WEB-INF/springapp-servlet.xml]: Cannot resolve reference to bean 'org.sakaiproject.logic.SakaiProxy' while setting bean property 'sakaiProxy'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.sakaiproject.logic.SakaiProxy' is defined
这是我的springapp-servlet.xml
<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-2.0.xsd">
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<!--<property name="prefix" value="/WEB-INF/jsp/" />-->
<property name="suffix" value=".jsp" />
<property name="order" value="10" />
</bean>
<bean name="/index.htm"
class="org.sakaiproject.tool.HelloWorldController">
<property name="sakaiProxy" ref="org.sakaiproject.logic.SakaiProxy"/>
</bean>
这是我的controller
package org.sakaiproject.tool;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.sakaiproject.logic.SakaiProxy;
public class HelloWorldController implements Controller {
/**
* Hello World Controller
*
* @author Mike Jennings (mike_jennings@unc.edu)
*
*/
private SakaiProxy sakaiProxy = null;
public ModelAndView handleRequest(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
Map<String, Object> map = new HashMap<String,Object>();
map.put("currentSiteId", sakaiProxy.getCurrentSiteId());
map.put("userDisplayName", sakaiProxy.getCurrentUserDisplayName());
return new ModelAndView("index", map);
}
}
我不知道为什么会出现这个错误我用谷歌搜索但没有太多帮助:(