niyue

学习Struts

In java, learning on January 28, 2005 at 2:34 AM

最近不断在看Struts方面的资料,应该说Struts已经是很成熟的一种技术了,在网上的相关介绍也是连篇累牍,但是看了能够增进理解有所帮助的还是比较难见到。下面是我觉得在Struts学习中对我有帮助的一些资料:

下面是我学习中遇到的一些困难及解决:

    • 在Tomcat上部署Struts的例子的时候碰到了问题,解决:Unable to find a javac compiler
    • 表单数据验证失败时发生错误,“No input attribute for mapping path”,原因是没有填写配置文件action中的input属性值。解决:Struts中不同的Action和ActionForm组合
    • 两次输入密码比较的验证,解决:Struts Validator: Validating Two Fields Match by Matt Raible. Howto article.开始漏看了最后一句重要的话,没看完就开始了,结果因为那个小问题浪费了两个多小时,真是不值得。
    • 实现下拉框时出现错误”Cannot find bean under name org.apache.struts.taglib.html.BEAN”。解决:JSP FAQ @ jGuru
    • 部署新的action时发生错误”No Action Instance for Path /CreateContent could be created”,开始在网上找了一下,发现大多数此类错误都是由于Action的type名称写错了,但是我仔细核对发现这里没有错,我的错误在于没有将Action的type类声明成public的!
    • 上面的数据验证的例子中采用的API调用已经被deprecated掉了,Struts 1.2用也还可以用,但是Eclipse里面会出来感叹号说不赞成使用ValidatorUtil和Resources.getActionError()方法,解决:Struts Upgrade Notes 11 to 124
    • 开了一个新的sample应用的时候,出现异常java.lang.IllegalArgumentException: Resources cannot be null.
      at org.apache.commons.validator.Validator.(Validator.java:188)
      后来发现是strut
      中没有添加validator插件,同时validation.xml文件和validator-rules.xml文件不存在
    • 使用Struts将应用分成为几个模块配置的时候,无论如何配置,一直出现找不到子模块中的action的异常,”Cannot retrieve mapping for action /mindforce/SubmitLogon”.后来发现原来是tab的链接没有通过action进行转发,而是直接写了要显示的jsp页面视图的url,因此struts进行模块间转换时无法自动识别,故action mapping找不到对应的action.正确的配置方法是:子模块中的action路径均填写模块下的相对路径,jsp页面中的action也填写相对于模块的路径而不要加上模块名称,struts会自动在模块切换时添加模块名.模块切换方法请见:5.3.3 Switching Modules

进行Struts开发时一些有用的工具:

    • Scioworks™ Camino

      Visual Modelling Tool for Struts

      Scioworks™ Camino is a visual modelling tool for Jakarta Struts Framework, the de-facto J2EE web MVC framework. Designed for rapid assembly of web applications, its unique visual drag-and-connect paradigm allows for rapid development and re-wiring of web application with minimal coding.

Exadel Struts Studio now supports Eclipse 3.0.x. This version includes design-time JSP Preview, JSP, CSS, JavaScript and XML Prompting with autocomplete functionality, Java debugging of Web applications under the Tomcat, JBoss and Sun J2EE SDK environment, and one-step adding of Struts support to J2EE projects created with other Eclipse plug-ins.

    • JamesHolmes.com

Struts Console

The Struts Console is a FREE standalone Java Swing application for developing and managing Struts-based applications. With the Struts Console you can visually edit JSP Tag Library, Struts, Tiles and Validator configuration files.

The Struts Console also plugs into multiple, popular Java IDEs for seamless management of Struts applications from one central development tool.

FWA Software‘s Visual Tags Dreamweaver extension suites for JSTL and Struts enable web developers to use Macromedia’s Dreamweaver MX web design and development product to

  • Visually design, implement, and maintain web pages for JSTL and Struts-based web applications
  • Rapidly prototype web pages for JSTL and Struts-based web applications
  • Exploit open source technologies with Dreamweaver to create JSTL and Struts-based web applications
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s