摘自org.apache.struts.taglib.html.HtmlTag也就是<html:html>对应的那个    /**
     * Process the start of this tag.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doStartTag() throws JspException {
        StringBuffer sb = new StringBuffer("<html");        // Use the current Locale to set our language preferences
        Locale currentLocale = this.getCurrentLocale();
        String lang = currentLocale.getLanguage();        // Does the locale have a language?
        boolean validLanguage = ((lang != null) && (lang.length() > 0));        if (this.xhtml) {
            this.pageContext.setAttribute(Globals.XHTML_KEY, "true", PageContext.PAGE_SCOPE);
            sb.append(" xmlns=\"http://www.w3.org/1999/xhtml\"");
        }        if ((this.locale || this.xhtml) && validLanguage) {
            sb.append(" lang=\"");
            sb.append(lang);
            sb.append("\"");
        }        if (this.xhtml && validLanguage) {
            sb.append(" xml:lang=\"");
            sb.append(lang);
            sb.append("\"");
        }        sb.append(">");        // Write out the beginning tag for this page
        ResponseUtils.write(this.pageContext, sb.toString());        // Evaluate the included content of this tag
        return (EVAL_BODY_INCLUDE);
    }

解决方案 »

  1.   

    在struts的早期版本中,<html:html>标签采用locale属性来完成和lang属性相同的功能。区别在于如果locale属性为“true”,并且不存在HttpSession,struts框架会创建HttpSession,然后把从HTTP请求中获得的Locale保存在HttpSession中。这种做法强制性地要求应用支持Session,不是很可取,所以locale属性在struts1.2版本中被lang属性所替代。