Spring mvc 在web.xml中添加ContextLoaderListener后。404错误为;请求的资源()不可用;
在我的spring mvc应用程序中,当我在web.xml文件中添加applicationContext.xml时:Spring mvc 在web.xml中添加ContextLoaderListener后。404错误为;请求的资源()不可用;,spring-mvc,Spring Mvc,在我的spring mvc应用程序中,当我在web.xml文件中添加applicationContext.xml时: <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param&
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
SpringJdbcService.java
package com.ankit.service;
import com.ankit.beans.Employee;
public interface SpringJdbcService {
Employee searchMemDts(Employee vngmem);
void insertMemDts(Employee MemDtlsbean);
}
SpringJdbcServiceImpl.java
package com.ankit.service.impl;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.stereotype.Service;
import com.ankit.beans.Employee;
import com.ankit.service.SpringJdbcService;
@Service
public class SpringJdbcServiceImpl implements SpringJdbcService {
public Employee searchMemDts(Employee vngmem) {
try {
vngmem.setEmployeeName("Ankit");
return vngmem;
} catch (BadSqlGrammarException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
我正试图点击以下网址:
localhost:8085/mvc/searchJdbcContact.html您可能应该阅读以下内容:。但您提供的信息不足以确定问题。我们不知道您的配置看起来像什么,您的映射是什么,以及您试图访问哪个URL。您的根和web上下文应该分为两个seprate配置。控制器/mvc Annotion在web上下文中定义。
package com.ankit.service;
import com.ankit.beans.Employee;
public interface SpringJdbcService {
Employee searchMemDts(Employee vngmem);
void insertMemDts(Employee MemDtlsbean);
}
package com.ankit.service.impl;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.stereotype.Service;
import com.ankit.beans.Employee;
import com.ankit.service.SpringJdbcService;
@Service
public class SpringJdbcServiceImpl implements SpringJdbcService {
public Employee searchMemDts(Employee vngmem) {
try {
vngmem.setEmployeeName("Ankit");
return vngmem;
} catch (BadSqlGrammarException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}