日期:2014-05-18  浏览次数:20626 次

帮忙看看applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<beans>
<bean id="login" class="org.LoginAction">
</bean>
</beans>


这段代码有错吗?

------解决方案--------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<beans>
<bean id="login" class="org.LoginAction">
</bean>
</beans>
</web-app>
------解决方案--------------------
应该是
<beans version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<bean id="login" class="org.LoginAction">
</bean>
</beans>
------解决方案--------------------
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
------解决方案--------------------
web-app是web.xml里的最外层标记,beans是spring配置文件的标记,复制粘贴都找不对地方吗?
------解决方案--------------------
第一:你是用什么软件开发的?myeclipse,可以自动生成配置文件,那样你就可以自动生成一个看看标签是否正确,第二:如果你用eclipse开发,你下载的spring,的完整的包中有application.xml配置,可以复制一个过来看看标签是否正确。
------解决方案--------------------
引用:
这是struts2和spring整合开发的applicationContext.xml 文件,不知道为什么会错

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="login" class="org.LoginAction">
</bean>
</beans>
 
------解决方案--------------------
<?xml version="1.0" encoding="UTF-8"?>