public void process (HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException { String screenName = null;
String localeString = null;
String selectedUrl = request.getRequestURI();
if (request.getSession().getAttribute(WebKeys.CURRENT_URL) != null) {
request.getSession().removeAttribute(WebKeys.CURRENT_URL);
}
/*这个if语句快有什么作用?从哪儿取值,为什么取出来以后又要remove掉呢?*/ String languageParam = request.getParameter("locale");
/*这个local从哪儿取呢?*/
// The language when specified as a parameter overrides the language set in the session
if (languageParam != null) {
localeString = languageParam;
} else if (request.getSession().getAttribute(WebKeys.LOCALE) != null) {
localeString = ((Locale)request.getSession().getAttribute(WebKeys.LOCALE)).toString();
/*这个又是从哪儿取的呢?*/
}
if (allScreens.get(localeString) == null) {
localeString = defaultLocale;
/*这儿的localString值是多少*/
} // get the screen name
int lastPathSeparator = selectedUrl.lastIndexOf("/") + 1;
int lastDot = selectedUrl.lastIndexOf(".");
if (lastPathSeparator != -1 && lastDot != -1 && lastDot > lastPathSeparator) {
screenName = selectedUrl.substring(lastPathSeparator, lastDot);
/*这儿的screenName是多少?*/
}
// check if request is for the previous screen
/*这个if语句块有什么作用?以下的看不懂了,请大家帮忙*/
if (screenName.equals(PREVIOUS_SCREEN)) {
String longScreenName = (String)request.getSession().getAttribute(WebKeys.PREVIOUS_SCREEN);
int lastDot2 = longScreenName.lastIndexOf(".");
if ( lastDot2 != -1 && lastDot2 > 0) {
screenName = longScreenName.substring(0, lastDot2);
}
// put the request attributes stored in the session in the request
if (cachePreviousScreenParameters) {
Map previousParams = (Map)request.getSession().getAttribute(WebKeys.PREVIOUS_REQUEST_PARAMETERS);
Map params = (Map)request.getParameterMap();
Iterator it = previousParams.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
Object value = previousParams.get(key);
params.put(key,value);
}
}
// put in the previous request attributes
if (cachePreviousScreenAttributes) {
Map previousAttributes = (Map)request.getSession().getAttribute(WebKeys.PREVIOUS_REQUEST_ATTRIBUTES);
Iterator it2 = previousAttributes.keySet().iterator();
// put the request attributes stored in the session in the request
while (it2.hasNext()) {
String key = (String)it2.next();
Object value = previousAttributes.get(key);
request.setAttribute(key,value);
}
}
} else {
String extension = selectedUrl.substring(lastDot, selectedUrl.length());
request.getSession().setAttribute(WebKeys.PREVIOUS_SCREEN, screenName + extension);
if (cachePreviousScreenParameters) {
// copy all the parameters into a new map
HashMap newParams = new HashMap();
Map params = (Map)request.getParameterMap();
Iterator it = params.keySet().iterator();
// put the request attributes stored in the session in the request
while (it.hasNext()) {
String key = (String)it.next();
Object value = params.get(key);
newParams.put(key,value);
}
request.getSession().setAttribute(WebKeys.PREVIOUS_REQUEST_PARAMETERS, newParams);
}
if (cachePreviousScreenAttributes) {
// put the request attributes into a map
HashMap attributes = new HashMap();
Enumeration enum = request.getAttributeNames();
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
Object value = request.getAttribute(key);
attributes.put(key, value);
}
request.getSession().setAttribute(WebKeys.PREVIOUS_REQUEST_ATTRIBUTES, attributes);
}
}
// get the screen information for the coresponding language
Screen screen = null;
if (screenName != null){
Screens localeScreens = (Screens)allScreens.get(localeString);
if (localeScreens != null) screen = (Screen)localeScreens.getScreen(screenName);
// default to the default locale screen if it was not defined in the locale specific definitions
if (screen == null) {
System.err.println("Screen not Found loading default from " + defaultLocale);
localeScreens = (Screens)allScreens.get(defaultLocale);
screen = (Screen)localeScreens.getScreen(screenName);
}
if (screen != null) {
request.setAttribute(WebKeys.CURRENT_SCREEN, screen);
String templateName = localeScreens.getTemplate(screenName);
if (templateName != null) {
insertTemplate(request, response, templateName);
}
} else {
response.setContentType("text/html;charset=8859_1");
PrintWriter out = response.getWriter();
out.println("<font size=+4>Error:</font><br>Definition for screen " + screenName + " not found");
}
}
} private void insertTemplate(HttpServletRequest request,
HttpServletResponse response,
String templateName)
throws IOException, ServletException { }
HttpServletResponse response)
throws IOException, ServletException { String screenName = null;
String localeString = null;
String selectedUrl = request.getRequestURI();
if (request.getSession().getAttribute(WebKeys.CURRENT_URL) != null) {
request.getSession().removeAttribute(WebKeys.CURRENT_URL);
}
/*这个if语句快有什么作用?从哪儿取值,为什么取出来以后又要remove掉呢?*/ String languageParam = request.getParameter("locale");
/*这个local从哪儿取呢?*/
// The language when specified as a parameter overrides the language set in the session
if (languageParam != null) {
localeString = languageParam;
} else if (request.getSession().getAttribute(WebKeys.LOCALE) != null) {
localeString = ((Locale)request.getSession().getAttribute(WebKeys.LOCALE)).toString();
/*这个又是从哪儿取的呢?*/
}
if (allScreens.get(localeString) == null) {
localeString = defaultLocale;
/*这儿的localString值是多少*/
} // get the screen name
int lastPathSeparator = selectedUrl.lastIndexOf("/") + 1;
int lastDot = selectedUrl.lastIndexOf(".");
if (lastPathSeparator != -1 && lastDot != -1 && lastDot > lastPathSeparator) {
screenName = selectedUrl.substring(lastPathSeparator, lastDot);
/*这儿的screenName是多少?*/
}
// check if request is for the previous screen
/*这个if语句块有什么作用?以下的看不懂了,请大家帮忙*/
if (screenName.equals(PREVIOUS_SCREEN)) {
String longScreenName = (String)request.getSession().getAttribute(WebKeys.PREVIOUS_SCREEN);
int lastDot2 = longScreenName.lastIndexOf(".");
if ( lastDot2 != -1 && lastDot2 > 0) {
screenName = longScreenName.substring(0, lastDot2);
}
// put the request attributes stored in the session in the request
if (cachePreviousScreenParameters) {
Map previousParams = (Map)request.getSession().getAttribute(WebKeys.PREVIOUS_REQUEST_PARAMETERS);
Map params = (Map)request.getParameterMap();
Iterator it = previousParams.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
Object value = previousParams.get(key);
params.put(key,value);
}
}
// put in the previous request attributes
if (cachePreviousScreenAttributes) {
Map previousAttributes = (Map)request.getSession().getAttribute(WebKeys.PREVIOUS_REQUEST_ATTRIBUTES);
Iterator it2 = previousAttributes.keySet().iterator();
// put the request attributes stored in the session in the request
while (it2.hasNext()) {
String key = (String)it2.next();
Object value = previousAttributes.get(key);
request.setAttribute(key,value);
}
}
} else {
String extension = selectedUrl.substring(lastDot, selectedUrl.length());
request.getSession().setAttribute(WebKeys.PREVIOUS_SCREEN, screenName + extension);
if (cachePreviousScreenParameters) {
// copy all the parameters into a new map
HashMap newParams = new HashMap();
Map params = (Map)request.getParameterMap();
Iterator it = params.keySet().iterator();
// put the request attributes stored in the session in the request
while (it.hasNext()) {
String key = (String)it.next();
Object value = params.get(key);
newParams.put(key,value);
}
request.getSession().setAttribute(WebKeys.PREVIOUS_REQUEST_PARAMETERS, newParams);
}
if (cachePreviousScreenAttributes) {
// put the request attributes into a map
HashMap attributes = new HashMap();
Enumeration enum = request.getAttributeNames();
while (enum.hasMoreElements()) {
String key = (String)enum.nextElement();
Object value = request.getAttribute(key);
attributes.put(key, value);
}
request.getSession().setAttribute(WebKeys.PREVIOUS_REQUEST_ATTRIBUTES, attributes);
}
}
// get the screen information for the coresponding language
Screen screen = null;
if (screenName != null){
Screens localeScreens = (Screens)allScreens.get(localeString);
if (localeScreens != null) screen = (Screen)localeScreens.getScreen(screenName);
// default to the default locale screen if it was not defined in the locale specific definitions
if (screen == null) {
System.err.println("Screen not Found loading default from " + defaultLocale);
localeScreens = (Screens)allScreens.get(defaultLocale);
screen = (Screen)localeScreens.getScreen(screenName);
}
if (screen != null) {
request.setAttribute(WebKeys.CURRENT_SCREEN, screen);
String templateName = localeScreens.getTemplate(screenName);
if (templateName != null) {
insertTemplate(request, response, templateName);
}
} else {
response.setContentType("text/html;charset=8859_1");
PrintWriter out = response.getWriter();
out.println("<font size=+4>Error:</font><br>Definition for screen " + screenName + " not found");
}
}
} private void insertTemplate(HttpServletRequest request,
HttpServletResponse response,
String templateName)
throws IOException, ServletException { }
解决方案 »
- ibatis不同目录配置文件加载不到sqlmap
- Quartz 应当导入哪个 Jar 包 ?
- 用ejb3 写了一个WebService的例子,发布在jboss里报错
- Expression.in长度问题 ???急急急
- Axis2 报错,生成wsdl不成功,请高人指点!
- java 中如何调用DB2存储过程返回的结果集
- 刚毕业,工作不久的困惑~请教高手指点!谢谢
- 本人很烦恼!现在还是一个软件开发的门外汉,怎么样才能提高啊
- 讨论TOMCAT和WEBLOGIC孰优孰劣?包括价格性能扩展性等等
- 用JB编写struts程序时,怎么老是出现这个问题,帮看一下?
- 大家帮我看一看一个struts问题
- 我在JNDI怎么不能找到Home接口呢,用的是zez老兄的那个例子.....
<servlet>
<servlet-name>TemplateServlet</servlet-name>
<display-name>TemplateServlet</display-name>
<servlet-class>com.sun.j2ee.blueprints.waf.view.template.TemplateServlet</servlet-class>
<init-param>
<param-name>cache_previous_screen_attributes</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>cache_previous_screen_parameters</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>default_locale</param-name>
<param-value>en_US</param-value>
</init-param>
<init-param>
<param-name>locales</param-name>
<param-value>en_US</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
以及mappings.xml和对应的screendefinitions_en_US.xml
总体都看看就知道了。
比如:String cachePreviousScreenAttributesString = config.getInitParameter("cache_previous_screen_attributes");
这个值从哪儿来的呢