我的配置文件如下:
//struts.xml<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"><struts>
<!--
<include file="com.ssh.struts.struts-user.xml"></include>
<constant name="struts.objectFactory" value="spring" />
-->
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
<package name="default" extends="struts-default" namespace="/login">
<action name="find" method="find" class="usersAction">
<result name="success" type="redirect">index.jsp</result>
<result name="failure" type="redirect">index.jsp</result>
</action>
</package></struts>web.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">
<!--
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/com/ssh/spring/applicationContext-*.xml
</param-value>
</context-param>
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:com/ssh/spring/applicationContext-*.xml
</param-value>
</context-param> <listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
//login/index.jsp<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>login jsp</title>
</head>
<script language="javascript" type="text/javascript">
function isblank(){
var user=document.lname.username.value;
var pass=document.lname.password.value;
if(user==""){
alert(5555);
alert("用户名为空,请您从新输入!!");
document.lname.username.focus();
return false;
}
if(pass==""){
alert("密码为空");
document.lname.password.focus();
return false;
}
return true;
}
</script>
<body>
<s:form name="lname" action="/login/find" method="post" onsubmit="return isblank()">
<s:textfield label="用户名:" name="username" id="userid" tooltip="enter your name"></s:textfield>
<s:textfield label="密码:" name="password" id="passid" tooltip="enter your pass"></s:textfield>
<s:submit></s:submit>
</s:form>
</body>
</html>applicationContext-resource.xml<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!--配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property> <property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property> <property name="username" value="zhang"></property> <property name="password" value="zhang"></property> <property name="maxActive" value="100"></property> <property name="maxIdle" value="30"></property> <property name="maxWait" value="500"></property> <property name="defaultAutoCommit" value="true"></property> </bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
<prop key="show_sql">true</prop>
<!-- <prop key="hbm2ddl.auto">update</prop> -->
</props>
</property>
<property name="mappingResources">
<list>
<value>com/ssh/login/entity/Users.hbm.xml</value>
</list>
</property>
</bean>
</beans>
applicationContext-action.xml<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="usersAction" class="com.ssh.login.action.UsersAction"
scope="prototype">
<property name="usersService">
<ref bean="usersService" />
</property>
</bean>
</beans>applicationContext-service.xml<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="usersService"
class="com.ssh.login.service.impl.UsersServiceImpl">
<property name="usersDao">
<ref bean="usersDao" />
</property>
</bean>
</beans>applicationContext-dao.xml<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="usersDao" class="com.ssh.login.dao.impl.UsersDaoImpl"
scope="singleton">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>
UsersAction.javapackage com.ssh.login.action;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.ServletActionContext;import com.opensymphony.xwork2.ActionSupport;
import com.ssh.login.service.UsersService;public class UsersAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private UsersService usersService;
public String find(){
HttpServletRequest request=ServletActionContext.getRequest();
String username=request.getParameter("username");
String password=request.getParameter("password");
String result=this.usersService.find(username);
if(result.equals(password)){
return "success";
}else{
return "failure";
}
} public UsersService getUsersService() {
return usersService;
} public void setUsersService(UsersService usersService) {
this.usersService = usersService;
}
}下面是我的工程结构图:
解决方案 »
- 求一个正则表达式...谢谢
- maximo 二级菜单问题
- getHibernateTemplate().save(u);不工作了,为什么??
- tomcat插件不能启动问题
- 反射的问题,代码不是很明白,求解释
- 各位老大帮帮忙一个HIBERNATE问题,在线等急!~!~!~!~
- 上传图片重命名后图片不显示了
- 我在java.sun.com里下载的j2ee服务器是一个window认不了的文件,(j2sdkee-1_3_1-win.exe)
- Eclipse+Tomcat4.1,启动时出现问题!
- 招聘高级JAVA程序员.
- jsp怎样输出异常????????????????????
- HibernateTemplate插入数据失败!急!!!
当我访问这个地址,提交的时候,直接就提示404HTTP Status 404 - /abin/login/find--------------------------------------------------------------------------------type Status reportmessage /abin/login/finddescription The requested resource (/abin/login/find) is not available.跳不到action 里面,求助
<s:textfield label="用户名:" name="username" id="userid" tooltip="enter your name"></s:textfield>
<s:textfield label="密码:" name="password" id="passid" tooltip="enter your pass"></s:textfield>
<s:submit></s:submit>
</s:form>就报的如下错误:
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: Unable to instantiate Action, usersAction, defined for 'find' in namespace '/login'Error creating bean with name 'usersAction' defined in file [D:\SystemFile\apache-tomcat-6.0.32\webapps\abin\WEB-INF\classes\com\ssh\spring\applicationContext-action.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService': no matching editors or conversion strategy found - action - file:/D:/SystemFile/apache-tomcat-6.0.32/webapps/abin/WEB-INF/classes/struts.xml:16:57
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
root cause Unable to instantiate Action, usersAction, defined for 'find' in namespace '/login'Error creating bean with name 'usersAction' defined in file [D:\SystemFile\apache-tomcat-6.0.32\webapps\abin\WEB-INF\classes\com\ssh\spring\applicationContext-action.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService': no matching editors or conversion strategy found - action - file:/D:/SystemFile/apache-tomcat-6.0.32/webapps/abin/WEB-INF/classes/struts.xml:16:57
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:294)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:365)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:83)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:74)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
root cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersAction' defined in file [D:\SystemFile\apache-tomcat-6.0.32\webapps\abin\WEB-INF\classes\com\ssh\spring\applicationContext-action.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService': no matching editors or conversion strategy found
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1130)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:125)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:113)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:275)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:365)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:83)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:74)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
root cause org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.ssh.login.service.impl.UsersServiceImpl] to required type [com.ssh.login.service.UsersService] for property 'usersService': no matching editors or conversion strategy found
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:125)
com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:143)
com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:113)
com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:275)
com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:365)
com.opensymphony.xwork2.DefaultActionInvocation.access$000(DefaultActionInvocation.java:38)
com.opensymphony.xwork2.DefaultActionInvocation$1.doProfiling(DefaultActionInvocation.java:83)
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
com.opensymphony.xwork2.DefaultActionInvocation.<init>(DefaultActionInvocation.java:74)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.
--------------------------------------------------------------------------------Apache Tomcat/6.0.32