我有带有 web.xml 配置的 spring 项目
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
这是我的 servlet-context.xml
resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**" />
<default-servlet-handler/>
<context:component-scan base-package="pk.training.basitMahmood.web.controller" />
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jspx" />
</beans:bean>
这是我的控制器
@RequestMapping("/contacts")
@Controller
public class ContactController {
final Logger logger = LoggerFactory.getLogger(ContactController.class);
@Autowired
private ContactService contactService;
@RequestMapping(method = RequestMethod.GET)
public String list(Model uiModel) {
logger.info("Listing contacts");
List<Contact> contacts = contactService.findAll();
uiModel.addAttribute("contacts", contacts);
logger.info("No. of contacts: " + contacts.size());
return "contacts/list";
}
} //end of class ContactController
现在,当我选择在服务器上运行时,我得到以下页面
但是当我将 url 更改为http://localhost:9090/ch17_i18nSupport/contacts
然后我得到错误
我的联系人文件夹中有 list.jspx。为什么我没有找到错误?
谢谢