需要导入spring的核心包和web包:Spring Core Librarles和 Spring Web Librarles
代码:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!--1、 配置请求的controller的业务类 -->
<bean id="loginController" class="com.ph.web.controller.LoginController">
<property name="formView" value="login"></property>
<property name="successView" value="showAccount"></property>
</bean>
<!--2、 配置controller和URL地址的映射关系 -->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<!--key是指的url地址 -->
<prop key="/login.do">loginController</prop>
</props>
</property>
</bean>
<!--3、 配置jsp作为视图解析器 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
|
|