用jb9集成struts1.1作一最简单的例子如下:
1.new project;
2.new ->web application;
3.new ->web->ActionForm,name为Untitled1ActionForm,添加一id,其他为默认设置
4.new->web->Action,name为Untitled1Action,FormBean name选第三步建立的formbean,scope->request,validate formbean->false,其他为默认设置
5.new->web->jsp from actionForm name为UntitledJsp1,actionForm选择第三步建立的formbean,其他为默认设置
6.在root directory下新建一jsp1.jsp.
7.修改action代码为:
public ActionForward excute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
return actionMapping.findForward("forward");
}
struts-config.xml 为:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="untitled1ActionForm" type="untitled7.Untitled1ActionForm" />
</form-beans>
<action-mappings>
<action name="untitled1ActionForm" type="untitled7.Untitled1Action" validate="false" scope="request" path="/untitled1Action">
<forward name="forward" path="/jsp1.jsp" />
</action>
</action-mappings>
</struts-config>UntitledJsp1部分代码为:
<html:form action="/untitled1Action.do" method="POST">
<html:text property="id"/>
<br>
<html:submit property="submit" value="Submit"/><br>
<html:reset value ="Reset"/>
</html:form>同样做法在struts1.0正常
1.new project;
2.new ->web application;
3.new ->web->ActionForm,name为Untitled1ActionForm,添加一id,其他为默认设置
4.new->web->Action,name为Untitled1Action,FormBean name选第三步建立的formbean,scope->request,validate formbean->false,其他为默认设置
5.new->web->jsp from actionForm name为UntitledJsp1,actionForm选择第三步建立的formbean,其他为默认设置
6.在root directory下新建一jsp1.jsp.
7.修改action代码为:
public ActionForward excute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
return actionMapping.findForward("forward");
}
struts-config.xml 为:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="untitled1ActionForm" type="untitled7.Untitled1ActionForm" />
</form-beans>
<action-mappings>
<action name="untitled1ActionForm" type="untitled7.Untitled1Action" validate="false" scope="request" path="/untitled1Action">
<forward name="forward" path="/jsp1.jsp" />
</action>
</action-mappings>
</struts-config>UntitledJsp1部分代码为:
<html:form action="/untitled1Action.do" method="POST">
<html:text property="id"/>
<br>
<html:submit property="submit" value="Submit"/><br>
<html:reset value ="Reset"/>
</html:form>同样做法在struts1.0正常
解决方案 »
- FreeMarker List问题
- 想实现个功能 在线等
- 请教一下struts验证框架的一个问题,谢谢来访!
- 定位特定属性值的节点,再在这个节点里的末尾添加新的子节点
- 用java编写一个借助堆栈把中缀表达式转换为后缀表达式的函数
- hibernate并发问题。
- 求助:初学者在Jboss中遇到的关于实体Bean的问题
- 在学j2ee已经装了jBuildX还用装j2ee sdk吗?
- 这种情况该不该用xslt 的第归转化?
- Docker里面镜像如何访问主机中间件
- struts中的actionform到底是怎么回事?我总是不明白。
- 网上有没有什么现成的邮件系统啊(javamail做的),就像新浪或者搜狐邮件那样的
解压后将webapps下的struts-example.war拷到%tomcat_home%\webapps\下
启动tomcat
在地址栏输入http://localhost:8080/struts-example/index.jsp就可以看到运行效果了struts\webapps\下的其他war包的部署方式类似开发自己的struts application,则只需将struts\lib\下的各个jar复制到你自己的web root\WEB-INF\lib下
然后按照struts的例子,修改web.xml,并添加自己的struts-config.xml到webroot\WEB-INF\下就ok了
当然,用到标签库的话,还得把相应的.tld文件复制到web.xml中配置的路径中去