首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web开发 >

SSH调整找不到action

2013-08-14 
SSH整合找不到action$(document).ready(function(){$(#username).blur(function isuser(){var username

SSH整合找不到action

$(document).ready(function(){
$("#username").blur(function isuser(){
var username=$("#username").val();
if(username==""){
$("#spanusername").html("请填写工号");
return false;
}
});
$("#password").blur(function ispass(){
var username=$("#username").val();
if(username==""){
$("#spanpassword").html("请填写密码");
return false;
}
});
$("#sub").click(function sub(){
var username=$("#username").val();
var password=$("#password").val();
$("#fom").attr("method","get");
$("#fom").attr("action","loginaction");
$("#fom").submit();
});
});



web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>OA</display-name>
  
  <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  
  <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
  </context-param>
  
  <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>


applicationContext.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"
         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.0.xsd


           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
          
 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
 <property name="driverClassName">
 <value>oracle.jdbc.driver.OracleDriver</value>
 </property>
 <property name="url">
 <value>jdbc:oracle:thin:@localhost:1521:orcl</value>
 </property>
 <property name="username">
 <value>scott</value>
 </property>
 <property name="password">
 <value>admin</value>
 </property>
 </bean>
 <bean id="user" class="com.entity.User"></bean>
 
 <bean id="UserDao" class="com.dao.impl.UserDaoImpl">
<property name="dataSource" ref="dataSource"/> 
 </bean>
 
 <bean id="loginactionbean" class="com.action.LoginAction"></bean>
</beans>



struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.objectFactory" value="spring"/>
<package name="user" extends="struts-default">
<action name="loginaction" class="loginactionbean" method="validation">
<result name="right">/index.jsp</result>
<result name="error">/login.jsp</result>
</action>
</package>
</struts>


LoginAction
package com.action;

import org.springframework.web.struts.ActionSupport;

import com.dao.IDao;
import com.entity.User;

public class LoginAction extends ActionSupport {

private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {


this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String validation(){
User user = new User();
user.setUsername(username);
user.setPassword(password);
IDao userDao=(IDao) this.getWebApplicationContext().getBean("UserDao");
boolean result=userDao.queryLogin(user);
if(result){
return "right";
}else{
return "errror";
}
}
}


目录结构
SSH调整找不到actionSSH调整找不到action
[解决办法]
jsp页面哪去?

热点排行