求解:使用ssh框架,为何调试时得不到画面上输入的值?

fedoriri 2012-08-14 06:55:13
ssh框架是自己用eclipse搭建的,断点调试时发现model里的msg的值为null,不知道为什么画面输入了值却传不到model中?求高手提示哈。
-------------ACTION类---------------
public class TESTACTION extends ActionSupport {
private static final long serialVersionUID = 1L;

private TESTMODEL model;
@Override
public String execute() throws Exception {
if ("badBoy".equals(this.model.getMsg())){
return ActionSupport.SUCCESS;
}else
{
return ActionSupport.ERROR;
}
}

public TESTMODEL getModel() {
return model;
}

public void setModel(TESTMODEL model) {
this.model = model;
}
}
----------model类---------------------
public class TESTMODEL {
private String msg;

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}

}
-----------------jsp-----------------
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-31j">
<title>TestCase</title>
</head>
<body>
<s:form action="helloAction" method="post">
<input type="text" name ="msg"></input>

<input type="submit" name ="submit" value="commit"></input>

</s:form>

</body>
</html>
...全文
147 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
fedoriri 2012-08-18
  • 打赏
  • 举报
回复
applicationContext.xml

<bean id="testAction" class="cn.co.action.TESTACTION"
scope="prototype">
<property name="model" ref="testModel" />
<property name="service" ref="testService" />
</bean>

<bean id="testModel" class="cn.co.model.TESTMODEL"
scope="prototype">
</bean>

<bean id="testService" class="cn.co.service.impl.TESTSERVICEImpl"
scope="prototype">
</bean>
fedoriri 2012-08-16
  • 打赏
  • 举报
回复
struts.xml
<struts>
<package name="firstStruts" namespace="/" extends="struts-default">
<action name="helloAction" class="testAction">
<result name="success">
/hello.jsp
</result>
<result name="error">
/error.jsp
</result>
</action>
</package>
</struts>
web.xml
<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>

<!-- 指明spring配置文件处 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<!-- applicationContext.xml -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
maliang18 2012-08-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

这里<input type="text" name ="msg"></input>
换成<input type="text" name ="model.msg"></input>
[/Quote]
正解
iamzep 2012-08-15
  • 打赏
  • 举报
回复
strut的配置文件发上来看看,按理来说用eclipse搭的话JSP的很多标签都会自己生成的
fedoriri 2012-08-15
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
这里<input type="text" name ="msg"></input>
换成<input type="text" name ="model.msg"></input>
[/Quote]

为什么需要写成这样啊?只写msg,model为什么不能自动得到值?
  • 打赏
  • 举报
回复
这里<input type="text" name ="msg"></input>
换成<input type="text" name ="model.msg"></input>
  • 打赏
  • 举报
回复
要通过TESTACTION 类定义一个对象,让对象调用getMsg()才能取到值。
fedoriri 2012-08-15
  • 打赏
  • 举报
回复
TESTACTION<T extends TESTMODEL> extends ActionSupport implements ModelDriven<T>
{
private T model;
public T getModel() {
return model;
}

public void setModel(T model) {
this.model = model;
}
}
fedoriri 2012-08-15
  • 打赏
  • 举报
回复
没人知道吗。。。。。。

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧