关于Spring MVC中action竟然没被调用。大家看看 源代码在此

FunnyRabbit 2010-10-18 02:15:29
问题就是在点击了main页面中的按钮后能够调到rlt这个页面,但是WelComeAction根本就没运行,System.out.println("%%%%%%%%%%%%%%%%%%%");这就都没运行

还有就是通过request.getParameter("prama1")我能获得页面中id为prama1这个文本框中的内容吗??


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>springmail</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springmail-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springmail</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/WEB-INF/jsp/main.jsp</welcome-file>
</welcome-file-list>


<?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="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="main.do">welcome</prop>
</props>
</property>
</bean>
<bean id="welcome" class= "com.action.WelComeAction">
<property name="commandClass">
<value>com.po.mailservice</value>
</property>
<property name="formView" value="main" />
<property name="successView" value="rlt" />
</bean>
</beans>


package com.action;

import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

public class WelComeAction extends SimpleFormController{
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response){
System.out.println("%%%%%%%%%%%%%%%%%%%");
String pra1 = request.getParameter("prama1");
String pra2 = request.getParameter("prama2");
System.out.println("!!!!!!!!!!!!!!!!!!!!!!:"+pra1+"@@@@@:"+pra2);
HashMap tojsp = new HashMap();
tojsp.put("pra1", request.getParameter("prama1"));
tojsp.put("pra2", request.getParameter("prama2"));
tojsp.put("pra3", "dfe");
tojsp.put("pra4","hgds");
return new ModelAndView(this.getSuccessView(),"tojsp",tojsp);
}
}



<%@ page language="java" pageEncoding="GB2312" contentType="text/html; charset=GB2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<body>
<form action="./main.do" method="post">
参数1:<input id="prama1" type="text" value="s"><br>
参数2:<input id="prama2" type="text" value="dfz"><br>
<input type="submit">
</form>
</body>
</html>
...全文
191 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
FunnyRabbit87 2010-11-19
没人回答
该结贴了
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2010-10-18 02:15
社区公告
暂无公告