http://localhost:8080/TestEJB/register.do 页面执行到这一步后就不执行了 没能进入相应的action
我的struts-config 如下
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="userForm" type="cn.actionForm.UserForm"></form-bean>
<form-bean name="userRegisterForm" type="cn.actionForm.UserRegisterForm"></form-bean>
</form-beans>
<action-mappings>
<action path="/login" name="userForm" scope="request" type="cn.action.UserLoginAction">
<forward name="success" path="/success.jsp" />
<forward name="input" path="/index.jsp" />
</action>
<action path="/register" name="userRegisterForm" scope="request" type="cn.action.UserRegisterAction">
<forward name="success" path="/success.jsp"/>
<forward name="input" path="/index.jsp"/>
</action>
</action-mappings>
</struts-config>
求指点~~~~
我的struts-config 如下
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="userForm" type="cn.actionForm.UserForm"></form-bean>
<form-bean name="userRegisterForm" type="cn.actionForm.UserRegisterForm"></form-bean>
</form-beans>
<action-mappings>
<action path="/login" name="userForm" scope="request" type="cn.action.UserLoginAction">
<forward name="success" path="/success.jsp" />
<forward name="input" path="/index.jsp" />
</action>
<action path="/register" name="userRegisterForm" scope="request" type="cn.action.UserRegisterAction">
<forward name="success" path="/success.jsp"/>
<forward name="input" path="/index.jsp"/>
</action>
</action-mappings>
</struts-config>
求指点~~~~
解决方案 »
- jsp问题(在线等解答)
- JPQL连接查询的问题
- 网站左右的分类列表是怎么做的
- Struts2.0的问题
- 问一下,apache的digester是否支持写XML文件?
- 如何用servlet实现服务器推技术?(拜请各位大侠不吝赐教)
- JSF无法获得 Spring 的配置信息
- 请高手帮忙: XML文件 转 对象类
- tomcat问题
- 高手,请来看一下:如何用不同的按钮控制画“不同的”形状(我想通过设置鼠标响应的不同变量值)
- 帮帮忙解决Could not initialize class org.apache.commons.beanutils.BeanUtils
- java 如何比较出离今天最近的日期 救急..谢谢
再发点代码看看吧
<filter-name>Encoding</filter-name>
<filter-class>cn.fileEncoding.Encoding</filter-class>
</filter> <filter-mapping>
<filter-name>Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet> <!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
测了一下没有进注册的action
发 action
login.jsp 执行的都很顺利 register.jsp 点提交后 浏览器地址改变为http://localhost:8080/TestEJB/register.do 页面白哗哗一片 啥都没有
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
ServletRequest request, ServletResponse response) throws Exception { UserRegisterForm ulf = (UserRegisterForm) form;
ActionForward af = null;
PersonDAO personDao = (PersonDAO) EJBFactory
.getEJB("PersonDAOBean/remote");
String name=ulf.getName();
int age=Integer.parseInt(ulf.getAge());
Date birthday=new SimpleDateFormat("yyyy-MM-dd").parse(ulf.getBirthday());
boolean sex=ulf.getSex()=="男"?true:false;
String cardID=ulf.getIdcardno();
try {
personDao.insertPerson(name,sex,age,birthday,cardID);
af = mapping.findForward("success");
} catch (Exception e) {
e.printStackTrace();
af = mapping.findForward("input");
}
return af;
}
在 execute 方法中打印东西看有出不?
控制台没有输出 我没有加log4j 我刚接触struts1 有点不太熟悉 还望指教 ~~~~~
<action path="/register" name="register" scope="request" type="cn.action.UserRegisterAction">
试试看
public ActionForward execute(ActionMapping mapping, ActionForm form,
ServletRequest request, ServletResponse response) throws Exception {// 这里加行
System.out.println("============execute========");
就有输出了咯看register.jsp 中 form 写的action,
用户名<input type="text" name="name"><br />
性别<input type="radio" name="sex" value="男">男
<input type="radio" name="sex" value="女">女<br />
生日<input type="text" name="birthday"/><br/>
年龄<input type="text" name="age"><br />
身份证号<input type="text" name="idcardno"><br />
<input type="submit" value="提 交">
</form>
在action打个断点
当点提交按钮后 页面跳转到http://localhost:8080/TestEJB/login.do 后就不执行了
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
ServletRequest request, ServletResponse response) throws Exception应该重写这个方法
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)