Thinking of building ssh and solving method of several problems encountered _jsp programming

Source: Internet
Author: User
Tags exception handling one more line
SSH has been in vogue for a long time, seeing both official documents and the Internet talking about how to integrate SSH and discuss the pros and cons of various integrations. Today I am more free and try to integrate the three most popular frameworks with some of my ideas.

The version used is: Struts 1.3.9 Spring 2.5 hiberante 3.2
Development tools and environment for: Eclipse 3.3+myeclipse 6.0+jboss 4.2+tomcat

With SSH, our architecture will naturally be divided into three layers, that is, the performance layer, the logical layer and the persistence layer, according to Martin Flower's guiding ideology, the less the coupling the better, the lower layer to provide services for the upper layer, which is the guiding rod to develop spring, one of the guidelines, So the first thing I think about is how to minimize the coupling.
Based on the practices recommended in the Spring 2.0 official documentation, Spring is integrated with struts1.x, it has a proxy class, and it works in a actionsupport way, but I think there is no doubt that these two approaches are highly intrusive and dependent, which is somewhat contradictory to spring's thinking.
I use Autowiringrequestprocessor to do, this class will automatically load the service you need, according to its Java doc prompts, its default is Bytype matching, of course, you can also use the byname way, I think it's OK to type the way it is. Take a look at the two profiles, first look at the struts configuration file Struts-config.xml:

1.? XML version= "1.0" encoding= "UTF-8"?>
2 <! DOCTYPE struts-config Public "-//apache Software foundation//dtd struts Configuration 1.3//en" "http:// Struts.apache.org/dtds/struts-config_1_3.dtd ">
3
4 < Struts-config >
5 < Form-beans >
6 < Form-bean name = "LoginForm" type = "Com.***.ssh.view.login.loginform"/>
7 </Form-beans >
8
9 < Global-exceptions/>
Ten < Global-forwards/>
< action-mappings >
< action name = "LoginForm" path = "/login" scope = "Request"
The type = "com.***.ssh.view.login.loginaction" validate = "false"/>
</action-mappings >
15
< controller
Processorclass = "Org.springframework.web.struts.AutowiringRequestProcessor"/>
18
< message-resources parameter = "Applicationresources"/>
</struts-config >
21st
22
As you can see in this file, there is one more line with no integration with spring:
<controller processorclass= "Org.springframework.web.struts.AutowiringRequestProcessor"/>

Let's look at spring's profile applicationcontext.xml:

1.? XML version= "1.0" encoding= "UTF-8"?>
2 <! DOCTYPE beans Public "-//spring//dtd bean//en" "Http://www.springframework.org/dtd/spring-beans.dtd" >
3
4 < Beans >
5
6 < Bean id = "Sshsessionfactory"
7 class = "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
8 < property name = "Configlocation" >
9 < value > Classpath:hibernate.cfg.xml </value >
Ten </Property >
One </bean >
12
< bean name = "Loginservice"
class = "Com.***.ssh.biz.login.loginservice" singleton = "false" >
< property name = "DAO" >
< ref bean = "Usersdao"/>
</Property >
</Bean >
19
< Bean id = "Usersdao" class = "Com.***.ssh.persistence.userdao" >
< property name = "Sessionfactory" >
< ref bean = "Sshsessionfactory"/>
</Property >
</Bean >
</Beans >
26
There is no superfluous content, there will be no proxy mode, multiple XML configuration at the same time, reduce the maintenance.
At the same time, you will find that I did not put the specific configuration of hibernate in this area, but with hibernate own configuration to manage.

In this way, the dependence between our three layers will be reduced to a level that can be exchanged at both ends.

By the way, the common books found above often do not have so in-depth discussion, is not afraid of beginners can not understand it?
In addition, for a schema, the problem that is to be solved does not refer to these, and we can use the Rup 4+1 view approach to consider all aspects of architecture. We can also from the following aspects to conquer: security, data input and output of the checksum conversion, internationalization, LOG, exception handling, heterogeneous system integration, background running procedures and so on. If there are multiple databases, we need to consider more transaction control.

I think I'm going to go ahead and refine this integration and implement a demo that is the basis for quick development of small simple projects.



The following issues have been encountered during consolidation:
Issue 1: "Critical: Error Listenerstart" When starting up
This problem, there are many solutions online:
One of the easiest ways to do this is to use listener initialization spring instead of initializing spring with a servlet, but this is not a good way to find the source, and the second is to create new problems.
A better solution is, plus log4j related configuration, and then start, will appear various details, which can be based on specific information to solve, the general may be DataSource configuration, or environmental configuration problems.
Reference URL: http://hi.baidu.com/xht314/blog/item/808ecf13c1dd1820dd5401af.html

Question 2: A hint of "Required extension qdox not found" encountered
Online also has the solution, I use the method is directly Commons-attributes-compiler.jar this bag to remove. Of course, if you want to use this package, you can refer to the following address:
Http://hi.baidu.com/sky_lei/blog/item/77ee17085543b232e8248824.html

Problem 3:struts packet conflict with spring package
I have a conflict with the package, instead of the priority of struts is OK, now the jar file is getting more and more troublesome, many of the project's jar files are messed up by developers, it seems that Maven is a good thing, at least the idea is good, may need to study the next step.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.